Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #19639 - Updated contributing to reflect model choices best pra…

…ctices.

Thanks charettes.
  • Loading branch information...
commit eaa716a4130bb019204669d32389db8b399c0f71 1 parent e2252bf
Tim Graham timgraham authored
Showing with 11 additions and 8 deletions.
  1. +11 −8 docs/internals/contributing/writing-code/coding-style.txt
19 docs/internals/contributing/writing-code/coding-style.txt
View
@@ -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.