Reputation: 19223
I have the following in my urls.py
if settings.DEBUG:
urlpatterns += patterns('',
(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT, 'show_indexes': True}),
)
And it does not work. I always get 'filename.txt' could not be found
If I change the URL from r'^static/(?P<path>.*)$'
to anything else, like for example r'^staticabc/(?P<path>.*)$'
it works.
Any idea how can I get this URL working?
Upvotes: 1
Views: 95
Reputation: 11888
see: https://docs.djangoproject.com/en/dev/howto/static-files/#configuring-static-files
In the "Serving the files" info box, it explains that this is done for you automatically if DEBUG = True
.
The version that it uses serves static files from the locations discovered by your STATICFILES_FINDERS
The extra definition you're providing overrides this one, and ONLY serves files from the STATIC_ROOT
, which will be empty unless you've just run collectstatic
will be empty.
Upvotes: 1