Opened 13 years ago

Closed 13 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

Description

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

In urls.py 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 by Jannis Leidel, 13 years ago

Resolution: invalid
Status: newclosed

This works as expected; see https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders for

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).

Version 0, edited 13 years ago by Jannis Leidel (next)
Note: See TracTickets for help on using tickets.
Back to Top