diff options
| author | Tim Graham <timograham@gmail.com> | 2013-01-24 06:53:32 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2013-01-24 07:59:39 -0500 |
| commit | eaa716a4130bb019204669d32389db8b399c0f71 (patch) | |
| tree | 3b2a0c4cc94e43a8f37f7522c6e46d3ab7982dcd /docs/internals/contributing/writing-code | |
| parent | e2252bf9772bdcc699e4cb8ff1eb4672965bda29 (diff) | |
Fixed #19639 - Updated contributing to reflect model choices best practices.
Thanks charettes.
Diffstat (limited to 'docs/internals/contributing/writing-code')
| -rw-r--r-- | docs/internals/contributing/writing-code/coding-style.txt | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/docs/internals/contributing/writing-code/coding-style.txt b/docs/internals/contributing/writing-code/coding-style.txt index 0d84cdac9a..21146600b4 100644 --- a/docs/internals/contributing/writing-code/coding-style.txt +++ b/docs/internals/contributing/writing-code/coding-style.txt @@ -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`` ------------------------------- |
