File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed
docs/internals/contributing/writing-code Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -136,14 +136,17 @@ Model style
136136 * ``def get_absolute_url()``
137137 * Any custom methods
138138
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+ )
147150
148151Use of ``django.conf.settings``
149152-------------------------------
You can’t perform that action at this time.
0 commit comments