I've just finished reading Two Scoops of Django: Best Practices for Django 1.5 by Daniel Greenfield and Audrey Roy, currently for sale as an e-book for $12 and easily the least expensive (except free) form of professional investment a Django developer can make.
Other topics include best practices for class based views, templates, how to structure apps, and plenty more.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'formatters': {
'verbose': {
'format':
'%(asctime)s %(name)s %(levelname)s %(module)s %(message)s',
'datefmt': '%Y-%m-%d %H:%M:%S'
},
'simple': {
'format': '%(asctime)s %(name)s %(levelname)s %(message)s',
'datefmt': '%Y-%m-%d %H:%M:%S'
},
},
'handlers': {
'null': {
'level': 'DEBUG',
'class': 'django.utils.log.NullHandler',
},
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple',
},
'file': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'filename': '/var/log/my_project/my_project.log',
'maxBytes': 20000000,
'backupCount': 5,
'formatter': 'verbose',
}
},
'loggers': {
'django': {
'handlers': ['null'],
'propagate': False,
'level': 'INFO',
},
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
'south': {
'handlers': ['null'],
'propagate': False,
'level': 'INFO',
},
'':{
'handlers': ['console', 'file'],
'level': 'DEBUG',
'propagate': True,
'disabled': False
}
}
}
import logging
LOG = logging.getLogger(__name__)
LOG.setLevel(logging.DEBUG)
def my_function(my_arg):
my_var = my_arg + 1
LOG.debug('my_var: %s' % my_var)
return my_var
Another place that could have done with some easy examples is reStructuredText; I know its the fancy way to document and could clicked a link learn all about it, but this book could give a little bit more to whet my whistle than "study the documentation for reStructuredText and learn at least the basics." How do others use it for django apps?
This is a good book and well-worth the money. It'll make you more productive, and so is easily worth the money. I look forward to reading further revisions.
Two Scoops of Django: Best Practices for Django 1.5
.jpg)