Fixed #19639 - Updated contributing to reflect model choices best practices.

Thanks charettes.
This commit is contained in:
Tim Graham 2013-01-24 06:53:32 -05:00
parent e2252bf977
commit eaa716a413
1 changed files with 10 additions and 7 deletions

View File

@ -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::
* 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::
DIRECTION_CHOICES = (
('U', 'Up'),
('D', 'Down'),
)
class MyModel(models.Model):
DIRECTION_UP = 'U'
DIRECTION_DOWN = 'D'
DIRECTION_CHOICES = (
(DIRECTION_UP, 'Up'),
(DIRECTION_DOWN, 'Down'),
)
Use of ``django.conf.settings``
-------------------------------