Is it possible to configure the output from the Django development server to show the IP address of the client making the request?
+2
A:
This in our list for "standard mods" to new Django releases. For Django 1.2.1, in django/core/servers/basehttp.py, line 614, change:
msg = "[%s] %s\n" % (self.log_date_time_string(), format % args)
to
msg = "[%s] %s %s\n" % (self.log_date_time_string(),
self.client_address[0], format % args)
Peter Rowell
2010-09-19 23:55:41
Thanks Peter! I just added it to my list of Django standard mods too. Bummer we have to mod the code to get it, but as the Django devs say, they make frameworks, not servers.
mitchf
2010-09-20 03:24:11
Any other "standard mods" you'd like to share? I'd love to see your list!
mitchf
2010-09-20 04:25:01
I looked through what we have and put the ones most likely to be of use to you up on PasteBin. http://pastebin.com/bjpS1mgg. In addition to what I showed above, there is a new method, `cache.get_or_eval()` that simplifies checking/setting the cache, and another that fixes the template variable resolution method so that a simply value, e.g. {{something}}, will be called if it is, in fact, a callable(). We use curried functions wrapped around heavy-weight DB calls and pass those in the context. Both fixes are MonkeyPatches and will be frowned on by some. Meh.
Peter Rowell
2010-09-20 16:27:15
Thank you for sharing those, Peter.
mitchf
2010-09-20 17:43:32
+1
A:
Other answers I've had suggested to me in my blog comments (source: http://mitchfournier.com):
- Consider Gunicorn as a dev server: http://gunicorn.org/ (orginNell)
- Consider using class inheritance on basehttp.py to create a new management command and avoid messing with the core code (orginNell)
- Use a real server (Harro)
- Write some middleware to log to a file (Harro)
- Consider replacing the built-in server with django-devserver: http://github.com/dcramer/django-devserver (mikeshantz)
- I like cherrypy with django: http://www.cherrypy.org/ (John M)
- Cherokee is very good too: http://www.cherokee-project.com/ (John M)
mitchf
2010-09-20 17:50:42
Wow! I think I go more out of *your* answer than you probably did out of mine. Thanks!
Peter Rowell
2010-09-21 02:02:54