Code

Opened 13 months ago

Closed 13 months ago

Last modified 13 months ago

#20634 closed Bug (fixed)

Discrepancy about staticfiles finders strategy

Reported by: claudep Owned by: nobody
Component: Documentation Version: master
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 timo 13 months ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 13 months ago by bmispelon

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.

Changed 13 months ago by timo

comment:2 Changed 13 months ago by timo

  • Has patch set

comment:3 Changed 13 months ago by claudep

  • Triage Stage changed from Accepted to Ready for checkin

comment:4 Changed 13 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 9be93aa809c34083ebef8392e52c83df0e383be3:

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

Thanks claudep for the catch and bmispelon for the research.

comment:5 Changed 13 months ago by Tim Graham <timograham@…>

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 Changed 13 months ago by jezdez

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.