Tips to a new django developer
blog.dpeepul.com
blog.dpeepul.com
if socket.gethostname() == 'productionserver.com':
DEBUG = False
else:
DEBUG = True
to if socket.gethostname() == 'developmentcomp':
DEBUG = True
else:
DEBUG = False
It's better practice to whitelist one box than to enable DEBUG on all computers but the production server - what if you deploy to another machine without thinking?http://ericholscher.com/blog/2008/nov/15/debugging-django-pr...
Sort of the best of both worlds.
DEBUG = socket.gethostname() == 'developmentcomp'
if DEBUG then...
DEBUG = socket.gethostname() == 'developmentcomp'More pinax discussion here: http://news.ycombinator.com/item?id=764566
1.How can we easily plug/unplug the django apps?
2.How easily can we customize a single app effectively?
Otherwise you'll end up doing this in multiple places throughout your views.
If your database supports it triggers, stored procedures and functions are probably a better way of achieving most of these things.
By putting a save method in your subclass you get access to the record about to be created or updated, you can use this to lift the id field out and do tricks with it just after insertion in to the database, or you can store the value of a field that can not be easily computed during data retrieval.
I use this in an application where each page appears as a leaf in a tree to update the path to the node based on the parent node and its path.
This forces me to think about my URL design up front. Then, if I decided I want to change URLs later, I've got plenty of time to come to my senses and stop. Public URLs shouldn't change, so this can only ever be a problem during development where a quick `vcs diff` renders the problem practically moot.
(EDIT: Added "Permalinks and" before "named URLs".)