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.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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/stable/internals/contributing/writing-code/coding-style/>`_
  10. `Code Like a Pythonista`_ is recommended reading.
  11. flake8_ and isort_ are used to enforce basic coding standards. To run these
  12. checks, use:
  13. $ make lint
  14. .. _Code Like a Pythonista: http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html
  15. .. _flake8: http://flake8.pycqa.org/en/latest/
  16. .. _isort: http://timothycrosley.github.io/isort/
  17. URLs
  18. ----
  19. * List pages should use plurals; e.g. ``/products/``, ``/notifications/``
  20. * Detail pages should simply be a PK/slug on top of the list page; e.g.
  21. ``/products/the-bible/``, ``/notifications/1/``
  22. * Create pages should have 'create' as the final path segment; e.g.
  23. ``/dashboard/notifications/create/``
  24. * URL names use dashes not underscores.
  25. * Update pages are sometimes the same as detail pages (i.e., when in the
  26. dashboard). In those cases, just use the detail convention, e.g.
  27. ``/dashboard/notifications/3/``. If there is a distinction between the detail
  28. page and the update page, use ``/dashboard/notifications/3/update/``.
  29. * Delete pages; e.g., ``/dashboard/notifications/3/delete/``
  30. View class names
  31. ----------------
  32. Classes should be named according to::
  33. '%s%sView' % (class_name, verb)
  34. For example, ``ProductUpdateView``, ``OfferCreateView`` and
  35. ``PromotionDeleteView``. This doesn't fit all situations, but it's a good basis.
  36. Referencing managers
  37. --------------------
  38. Use ``_default_manager`` rather than ``objects``. This allows projects to
  39. override the default manager to provide domain-specific behaviour.
  40. HTML
  41. ----
  42. Please indent with four spaces.