This site runs best with JavaScript enabled.

Django Model Style Guide


The preferred order of Model classes and methods

(This post is mostly for my own reference)

James Bennett mentions a Django style guide in his book Practical Django Projects.

I couldn't find reference to it, but the following is the order of things when it comes to models:

  1. Any constants and/or lists of choices
  2. The full list of fields
  3. The Meta class if present
  4. The Admin class if present
  5. The unicode() method
  6. The save() method, if its being overridden
  7. The get_absolute_url() method, if present
  8. Any additional custom methods

Discuss on TwitterEdit post on GitHub

Share article
Dustin Davis

Dustin Davis is a software engineer, people manager, hacker, and entreprenuer. He loves to develop systems and automation. He lives with his wife and five kids in Utah.

Join the Newsletter



Dustin Davis