Reputation: 5327
I'm facing quite a strange issue with Django, my STATIC_URL
is /static/
and I've got an app installed using pip
as -e git+git://github.com/foo/bar.git#egg=bar
which loads it into the virtualenv src folder.
Now, I'm trying to GET a static file related to this app as /static/bar/js/something.js
and the src folder does have a bar/bar/static/bar/js/something.js
file. Even if I findstatic
bar/js/something.js
it gives me a valid path to the file. However when I access it using the browser, I'm 301'd to /static/bar/js/something.js/
which 404s.
Why would this be happening?
Even poking around with staticfiles
app, I was able to see that it recognizes my app as installed and that its static
folder exists. However somehow the static files aren't being served.
Upvotes: 1
Views: 1843
Reputation: 53971
Make sure that you have set up the django development server to actually server the static files for you.
urls.py
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
# ... the rest of your URLconf goes here ...
urlpatterns += staticfiles_urlpatterns()
Upvotes: 3
Reputation: 2358
Try using this urlpattern:
url( r'(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/path/to/file/'}),
Upvotes: 1