Django in Production
October 20th, 2009
Q: How to determine if site is in local or production setup?
A: Create a production.py in your production site. In your settings.py, add the following lines:
try:
import production
PRODUCTION = True
except ImportError:
PRODUCTION = False
Wherever in your code, you can do the following:
from django.conf import settings
...
if settings.PRODUCTION:
# code for production...
else:
# code for local...
Neat eh?



Recent Comments