Opened 6 years ago

Closed 6 years ago

#16720 closed Bug (invalid)

staticfiles_urlpatterns looks for files in MEDIA_ROOT, not STATIC_ROOT

Reported by: dramon@… Owned by: nobody
Component: contrib.staticfiles Version: 1.3
Severity: Normal Keywords: staticfiles STATIC_ROOT
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


In new project I set this:
MEDIA_ROOT = '/someprj/media/'
MEDIA_URL = '/media/'
STATIC_ROOT = '/someprj/static/'
STATIC_URL = '/static/'
#    'django.contrib.staticfiles.finders.FileSystemFinder',
#    'django.contrib.staticfiles.finders.AppDirectoriesFinder',

In I added at the end:
urlpatterns += staticfiles_urlpatterns()

In directory /someprj/static/ exists file test.txt
When I try to access this file on http://localhost:8000/static/test.txt error page is returned.
When a copy this file to /someprj/media/, Django shows it.

Change History (1)

comment:1 Changed 6 years ago by Jannis Leidel

Resolution: invalid
Status: newclosed

This works as expected; see

STATIC_ROOT is the location the collectstatic management command deploys file to, not collects from.

The DefaultStorageFinder finder is simply a helper to include the files stored by the default storage backend (which is used for file uploads).

Last edited 6 years ago by Jannis Leidel (previous) (diff)
Note: See TracTickets for help on using tickets.
Back to Top