Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

…ctices.

Thanks charettes.
  • Loading branch information...
commit eaa716a4130bb019204669d32389db8b399c0f71 1 parent e2252bf
Tim Graham authored January 24, 2013
19  docs/internals/contributing/writing-code/coding-style.txt
@@ -136,14 +136,17 @@ Model style
136 136
   * ``def get_absolute_url()``
137 137
   * Any custom methods
138 138
 
139  
-* If ``choices`` is defined for a given model field, define the choices as
140  
-  a tuple of tuples, with an all-uppercase name, either near the top of
141  
-  the model module or just above the model class. Example::
142  
-
143  
-      DIRECTION_CHOICES = (
144  
-          ('U', 'Up'),
145  
-          ('D', 'Down'),
146  
-      )
  139
+* If ``choices`` is defined for a given model field, define each choice as
  140
+  a tuple of tuples, with an all-uppercase name as a class attribute on the
  141
+  model. Example::
  142
+
  143
+    class MyModel(models.Model):
  144
+        DIRECTION_UP = 'U'
  145
+        DIRECTION_DOWN = 'D'
  146
+        DIRECTION_CHOICES = (
  147
+            (DIRECTION_UP, 'Up'),
  148
+            (DIRECTION_DOWN, 'Down'),
  149
+        )
147 150
 
148 151
 Use of ``django.conf.settings``
149 152
 -------------------------------

0 notes on commit eaa716a

Please sign in to comment.
Something went wrong with that request. Please try again.