Python Styleguide

These are general rules for working with the Django Framework.

Testing Code

  • All files (except urls.py and __init__.py) should be tested (aim for 95% coverage).
  • I recommend installing django-coverage and django-nose libraries and creating a testing alias REUSE_DB=1 python manage.py test.
  • Test file structure should model actual app file structure inside the test directory. For each file in the app, create a relative pathed testing file that is the name of the app file prefixed with test_. So for the model tests, you would create a file {app_name}/tests/test_models.py, while for templatetags, you would create a file {app_name}/tests/templatetags/test_{your_templatetag}.py.