I found this in stackoverflow some time ago. Not sure who to thank but it works for me ...

import socket
if socket.gethostname() == '<your dev machine name here>':
    DEBUG = True
else:
    DEBUG = False


hth

Mike


On 22/11/2011 8:03am, Jim wrote:
Hello,

Inside of my settings.py I'd like to know whether I am running under
the development server (as in "python manage.py runserver") or in
another context.  For instance, I might want to set DEBUG or some
paths based on it.

I've had trouble finding documentation on it.  For instance, the
discussion here relies on settings.py having access to the request (or
in other responses to following some individual's conventions):
   
http://stackoverflow.com/questions/1291755/how-can-i-tell-whether-my-django-application-is-running-on-development-server-or
And the discussion here does not mention the issue, and it is where I
would expect to find the "recommended" approach:
   https://code.djangoproject.com/wiki/SplitSettings

I expect I'm missing something perfectly obvious.  I'd be grateful for
a tip-off about what it is.

Thanks,
Jim


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to