Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[1.5.x] Fixed #19639 - Updated contributing to reflect model choices …

…best practices.

Thanks charettes.

Backport of eaa716a from master
  • Loading branch information...
commit d571894fc09b34b8b43cb8f1790c743a47679851 1 parent 9328ef0
@timgraham timgraham authored
Showing with 11 additions and 8 deletions.
  1. +11 −8 docs/internals/contributing/writing-code/coding-style.txt
View
19 docs/internals/contributing/writing-code/coding-style.txt
@@ -136,14 +136,17 @@ Model style
* ``def get_absolute_url()``
* Any custom methods
-* If ``choices`` is defined for a given model field, define the choices as
- a tuple of tuples, with an all-uppercase name, either near the top of
- the model module or just above the model class. Example::
-
- DIRECTION_CHOICES = (
- ('U', 'Up'),
- ('D', 'Down'),
- )
+* If ``choices`` is defined for a given model field, define each choice as
+ a tuple of tuples, with an all-uppercase name as a class attribute on the
+ model. Example::
+
+ class MyModel(models.Model):
+ DIRECTION_UP = 'U'
+ DIRECTION_DOWN = 'D'
+ DIRECTION_CHOICES = (
+ (DIRECTION_UP, 'Up'),
+ (DIRECTION_DOWN, 'Down'),
+ )
Use of ``django.conf.settings``
-------------------------------
Please sign in to comment.
Something went wrong with that request. Please try again.