I am trying to serve static media (such as JS and CSS files, not user uploaded content) on a Webfaction-hosted Django setup. I tried to implement what was suggested in the second answer here (http://community.webfaction.com/questions/1148/serving-django-static-media-from-within-the-application) but I can't seem to get it working. My current set-up is as follows. The static media is stored in django/PROJECT/static. A symbolic static-only app called "static" is linked to django/PROJECT/static as well. The static app is added to the website under the directory /static. Static files in Django are accessed like "{{ STATIC_URL }}example.css". settings.py:
Suffice to say, I can't get any of my static files to load. If I browse to USERNAME.webfactional.com/static/example.css I get a 404 Not Found. How can I get static media working? Thanks for any help you can provide. (One note: I am also planning on using user-uploaded content, hence why I am using STATIC_ instead of MEDIA_). asked 22 Aug '11, 23:07 albeit |
Just to confirm - are you certain that the path:
exists on your server? Also, your
as the leading slashes are necessary to designate a path as absolute, rather than relative. Hope that helps! answered 22 Aug '11, 23:27 ryans ♦♦ Doh. I recently changed my static media directory from "media" to "static" locally, commited in git and pushed up the server, but didn't realized I needed to re-add "static" before I commited... learning Git as well. Thanks for the help! The leading slashes were there I just forgot them when I typed this. But yep, the PROJECT/static directory didn't even exist, so that was the problem. Thanks again.
(22 Aug '11, 23:42)
albeit
|
I get an error when running collectstatic if I have the same line in STATIC_ROOT and STATICFILES_DIR. ImproperlyConfigured: The STATICFILES_DIR setting should not contain the STATIC_ROOT setting. answered 26 Jul '13, 16:58 payetti @payetti : I believe that the above accepted answer to this question above is incorrect (although it may have been correct when it was originally posted in 2011.
(26 Jul '13, 17:05)
seanf
That makes sense. Things are finally up an running. Thanks Sean.
(26 Jul '13, 20:27)
payetti
|