News for hackers. Stuff that matters.
Re:Tips to a new django developer by outotrai on Monday August 31, 2009 @07:32AM (#795732)
A thought on security - I think #5 should be changed from

    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?
Re:Tips to a new django developer by jonknee on Monday August 31, 2009 @07:44AM (#795738)
You're right. Another handy way to do this is to keep debug as False and use middleware to show the debug error if you're logged in as an admin or from an IP that matches in INTERNAL_IPS:

http://ericholscher.com/blog/2008/nov/15/debugging-django-pr...

Sort of the best of both worlds.

Re:Tips to a new django developer by jksmith on Monday August 31, 2009 @03:40PM (#796562)
Please, for the love of conciseness, never assign a boolean based on an if statement.
Re:Tips to a new django developer by dmoho on Monday August 31, 2009 @03:54PM (#796589)
What if the assignment to the boolean was only one of the things you wanted to execute based on the result of the if statement?
Re:Tips to a new django developer by jksmith on Monday August 31, 2009 @05:50PM (#796803)
Even then, I'd rather see:

DEBUG = socket.gethostname() == 'developmentcomp'

if DEBUG then...

Re:Tips to a new django developer by rbanffy on Monday August 31, 2009 @04:33PM (#796661)
It's not
Re:Tips to a new django developer by aichcon on Monday August 31, 2009 @04:20PM (#796634)
How would you rewrite it?
Re:Tips to a new django developer by jpeterson on Monday August 31, 2009 @05:01PM (#796711)

  DEBUG = socket.gethostname() == 'developmentcomp'
Re:Tips to a new django developer by pvg on Monday August 31, 2009 @04:56PM (#796702)
An odd thing thing about this piece of advice is that it contradicts a lot of the previous advice which is 'don't hardcode stuff' This pattern is questionable for another reason - basing the app's configuration on some other, largely unrelated configuration (in this case, that of the network) can lead to elusive and annoying bugs. Configuration problems are much easier to debug when an application is told what its configuration is rather than trying to magically divine it from its environment.