Last modified 4 years ago Last modified on 06/15/2013 10:18:19 PM

Code Style


Indent with 4 spaces.

Imports should be just modules divided into four sections: Python modules, Django official modules, other apps modules and local app modules, separated by empty line. Non-local app Django modules with common name (models, utils, views...) should be renamed. The only exception is ugettext_lazy. Imports should be ordered alphabetically. Example:

import os
import time

from django.conf import settings
from django.contrib.auth import models as auth_models
from import base as management_base
from django.db import db_models
from django.db import utils as db_utils
from django.utils import encoding as utils_encoding
from django.utils.translation import ugettext_lazy as _

from registration import models as registration_models

from myapp import models

Every class, method and function has a docstring with description. Docstrings should be split into multiple lines when needed to improve readability.