You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

coding-style.rst 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. ============
  2. Coding Style
  3. ============
  4. General
  5. -------
  6. Please follow these conventions while remaining sensible:
  7. * `PEP8 -- Style Guide for Python Code <http://www.python.org/dev/peps/pep-0008/>`_
  8. * `PEP257 -- Docstring Conventions <http://www.python.org/dev/peps/pep-0257/>`_
  9. * `Django Coding Style <http://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/>`_
  10. `Code Like a Pythonista`_ is recommended reading.
  11. .. _Code Like a Pythonista: http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html
  12. URLs
  13. ----
  14. * List pages should use plurals; e.g. ``/products/``, ``/notifications/``
  15. * Detail pages should simply be a PK/slug on top of the list page; e.g.
  16. ``/products/the-bible/``, ``/notifications/1/``
  17. * Create pages should have 'create' as the final path segment; e.g.
  18. ``/dashboard/notifications/create/``
  19. * URL names use dashes not underscores.
  20. * Update pages are sometimes the same as detail pages (i.e., when in the
  21. dashboard). In those cases, just use the detail convention, eg
  22. ``/dashboard/notifications/3/``. If there is a distinction between the detail
  23. page and the update page, use ``/dashboard/notifications/3/update/``.
  24. * Delete pages; e.g., ``/dashboard/notifications/3/delete/``
  25. View class names
  26. ----------------
  27. Classes should be named according to::
  28. '%s%sView' % (class_name, verb)
  29. For example, ``ProductUpdateView``, ``OfferCreateView`` and
  30. ``PromotionDeleteView``. This doesn't fit all situations, but it's a good basis.
  31. Referencing managers
  32. --------------------
  33. Use ``_default_manager`` rather than ``objects``. This allows projects to
  34. override the default manager to provide domain-specific behaviour.
  35. HTML
  36. ----
  37. Please indent with four spaces.