Fixed #19639 - Updated contributing to reflect model choices best practices.
Thanks charettes.
This commit is contained in:
parent
e2252bf977
commit
eaa716a413
|
@ -136,14 +136,17 @@ Model style
|
||||||
* ``def get_absolute_url()``
|
* ``def get_absolute_url()``
|
||||||
* Any custom methods
|
* Any custom methods
|
||||||
|
|
||||||
* If ``choices`` is defined for a given model field, define the choices as
|
* If ``choices`` is defined for a given model field, define each choice as
|
||||||
a tuple of tuples, with an all-uppercase name, either near the top of
|
a tuple of tuples, with an all-uppercase name as a class attribute on the
|
||||||
the model module or just above the model class. Example::
|
model. Example::
|
||||||
|
|
||||||
DIRECTION_CHOICES = (
|
class MyModel(models.Model):
|
||||||
('U', 'Up'),
|
DIRECTION_UP = 'U'
|
||||||
('D', 'Down'),
|
DIRECTION_DOWN = 'D'
|
||||||
)
|
DIRECTION_CHOICES = (
|
||||||
|
(DIRECTION_UP, 'Up'),
|
||||||
|
(DIRECTION_DOWN, 'Down'),
|
||||||
|
)
|
||||||
|
|
||||||
Use of ``django.conf.settings``
|
Use of ``django.conf.settings``
|
||||||
-------------------------------
|
-------------------------------
|
||||||
|
|
Loading…
Reference in New Issue