I'm following Django's provided tutorial, but I've now discovered that jQuery isn't being loaded, so collapsible fieldsets in the administration panel do not work. This was because libjs-jquery wasn't yet installed on the system, but installing did not fix the problem.
Page not found (404)
Request Method: GET
Request URL: http://mysite:8000/static/admin/js/jquery.js
I've confirmed that /usr/share/pyshared/django/contrib/admin/media/js/jquery.js points to the correct file (/usr/share/javascript/jquery/jquery.js) and that the aforementioned /usr/.../js/ directory is where mysite:8000/static/admin/js/ reads from. I've also noticed that creating a new file in that /usr/.../js/ folder does not make it appear on the site itself. My best guess is that Django does not recheck the filesystem unless told to do so. Does anyone know how开发者_开发问答 I should fix this problem?
python manage.py collectstatic
might fix it;
It's better to serve your media through some other server and not your django instance though. For example nginx. is DEBUG set to true in your settings? If not it won't serve media for you.
I ended up veering from the tutorial and using Apache to run the site and serve the static content separately. I still don't know why the built-in 'runserver' insisted on returning a 404 for a file that existed, but clearly it is a subpar choice for serving static files.
精彩评论