I am starting work on a mature Django project and notice something unusual. When I edit urls.py -- whether at the project level or below -- Django ignores my changes.
Debugging is on, so when I get a 404 Django prints all the URL patterns it tried. From this I see the URL patterns from before I made my changes.
Again, this is regardless of whether I edit /project/urls.py or /project/sub/urls.py. To be sure, the subdirectory urls.py is being included correctly.
I am focusing on the project level urls.py, just in case.
I can make a small update to urls.py or delete all of its contents. The 404 debug info shows the old url patterns.
It is as if Django is looking at a cached开发者_如何学运维 version of these urls.py files. How should I proceed?
By deafult, Django's development server (accessed via the runserver
management command) will keep an eye on your code and reload itself whenever something changes. If you are using any other server (including Django's testserver
command) this is almost certainly not the case.
Typically, a server will load the source of your application when it starts. It will need to be reloaded to get the latest copy of your code. If you are using Apache with mod_wsgi (probably the most common production server for Django applications), somewhere in your source tree you will have a wsgi application file. By convention these have a .wsgi
extension, but it can be named anything. This file is what Apache uses to load your source and a useful feature of mod_wsgi (daemon mode only) is that touching (changing the modification date) this file is enough to force the server to erload the source code. If your application has a wsgi file you can edit, doing so and re-uploading the code should be enough. The file is likely to contain the line application = django.core.handlers.wsgi.WSGIHandler()
or something like it - this may help you
If you do not have access or you cannot find any such file, you will need to give the updated source to the server's administrator and ask them to update and reload the source. It's tricky to give you more advice without more information - perhaps you could ask the server administrator for more information so we can be mroe helpful?
== Update ==
I've checked the response headers on the link you've provided and it looks like you are using nginx to serve the site. This may just be a load-balancer in front of another server though, so I'd still recommend asking for more info from your SysAdmin.
精彩评论