Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#20634 closed Bug (fixed)

Discrepancy about staticfiles finders strategy

Reported by: Claude Paroz Owned by: nobody
Component: Documentation Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Tutorial 6 says:
Django will choose the first static file it finds whose name matches
https://docs.djangoproject.com/en/dev/intro/tutorial06/#customize-your-app-s-look-and-feel

Static files howto says:
Django will use the last static file it finds whose name matches
https://docs.djangoproject.com/en/dev/howto/static-files/#configuring-static-files

Documentation for STATICFILES_FINDERS could also tell something about this strategy.
https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders

Attachments (1)

20634.diff (1.6 KB ) - added by Tim Graham 11 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 by Baptiste Mispelon, 11 years ago

The tutorial is the correct one.

It's consistent with the template loaders mechanism: Django goes through each loader and if a match is found, it returns it.

Each loader is then free to implement its own logic, but the default ones work on a "first match returned" basis:

  • FileSystemFinder goes through each directory in settings.STATICFILES_DIR (in order) and returns the first match.
  • AppDirectoriesFinder goes through each app in settings.INSTALLED_APPS (in order) and return the first match too.

The collectstatic command will also only handle the first match. That is, if it finds a static file whose name has already been handled, it skips it.

by Tim Graham, 11 years ago

Attachment: 20634.diff added

comment:2 by Tim Graham, 11 years ago

Has patch: set

comment:3 by Claude Paroz, 11 years ago

Triage Stage: AcceptedReady for checkin

comment:4 by Tim Graham <timograham@…>, 11 years ago

Resolution: fixed
Status: newclosed

In 9be93aa809c34083ebef8392e52c83df0e383be3:

Fixed #20634 - Corrected doc mistake re: staticfiles finders strategy.

Thanks claudep for the catch and bmispelon for the research.

comment:5 by Tim Graham <timograham@…>, 11 years ago

In 519fdacf5127540638f7c1b4a3656d9a31f16a8b:

Fixed #20634 - Corrected doc mistake re: staticfiles finders strategy.

Thanks claudep for the catch and bmispelon for the research.

Backport of 9be93aa809 from master.

comment:6 by Jannis Leidel, 11 years ago

This may have been introduced during the last staticfiles docs refactor in February. :-/

Note: See TracTickets for help on using tickets.
Back to Top