django: Changing URL Patterns gets only applied when I restart Eclipse
If I change anything in my python sourcecode of my dj开发者_运维知识库ango webapplication it gets applied as soon as I save the changes. I can test it right away locally in my browser. However when I change url patterns in my urls.py I apparently have to restart eclipse until these changes get applied? Whats going on here?
Update
I'm using Eclipse Helios on Windows 7, 64 bit and Python 2.7.1
Update 2
I am sorry but I have to correct myself: No changes at all to the sourcecode get applied, not only changes to the urlpatterns. Only changes to the template-files get applied right away.
I therefore created a new thread: Django: How to restart webserver so that changes in sourcecode get applied
Sorry!
Restarting the server will pick up the changes, sounds like either the server isn't being restarted correctly, or perhaps there is a browser caching issue. (Try clearing the cache, see if that helps). If you are running the django server as a run configuration in eclipse, then you should see the incoming requests.
What do the changes in your urls.py look like? Do you have any middleware that are processing the incoming urls first?
Perhaps there is something in your request that's not getting picked up. When testing, I sometimes print out the requests as they come in before they're handled by urls.py to see what they contain. You can create a middleware module, like:
myproject.middleware.logrequest - (the module location / filename):
from django.conf import settings
from django.core.urlresolvers import reverse
from logging import getLogger
log = getLogger('my.log')
class LogRequestMiddleware(object):
def process_request(self, request):
parameters = []
for key, value in request.REQUEST.items():
parameters.append('{0}:{1}'.format(key,value))
log.debug('REQUEST: {0}'.format(', '.join(parameters)))
Then, in settings add it to MIDDLEWARE_CLASSES near the top (I put it just under 'django.middleware.common.CommonMiddleware') - in this case, the name would be: 'myproject.middleware.logrequest.LogRequestMiddleware'
I use logging in this case, but print should work just as well.
I don't use eclipse, so I'm not sure if it's supposed to auto update, but with my server, if I changed settings or urls, I have to stop/start the server, if I change any other .py file I just have to restart, and templates get updated instantly. I've always just accepted that that's the way it has to be for the code to recompile and update.
Try writing some scripts so that it's as easy as calling ./stop ./start ./restart
FYI, I use a purely terminal environment and Nginx & Gunicorn for serving
update: wait, do you mean you have to completely restart eclipse? or just the server part? If the first option, I feel very off topic.
精彩评论