summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2005-12-09 01:53:30 +0000
committerAdrian Holovaty <adrian@holovaty.com>2005-12-09 01:53:30 +0000
commit8da17bacf337117b1912fe12ce591a25a7e56021 (patch)
tree1c48e6a8646e9a216d8b8217f9bd7bbea70e27f9
parent36f1aef5ff05270462afcc54caddf82f7c4dbbfa (diff)
Fixed #972 -- Improved docs for 'choices' model field option. Thanks, radek
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1570 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--docs/model-api.txt19
1 files changed, 19 insertions, 0 deletions
diff --git a/docs/model-api.txt b/docs/model-api.txt
index 3245b2a78a..a6e5adf917 100644
--- a/docs/model-api.txt
+++ b/docs/model-api.txt
@@ -104,6 +104,25 @@ The following arguments are available to all field types. All are optional.
The first element in each tuple is the actual value to be stored. The
second element is the human-readable name for the option.
+ Define the choices list **outside** of your model class, not inside it.
+ For example, this is not valid::
+
+ class Foo(meta.Model):
+ GENDER_CHOICES = (
+ ('M', 'Male'),
+ ('F', 'Female'),
+ )
+ gender = meta.CharField(maxlength=1, choices=GENDER_CHOICES)
+
+ But this is valid::
+
+ GENDER_CHOICES = (
+ ('M', 'Male'),
+ ('F', 'Female'),
+ )
+ class Foo(meta.Model):
+ gender = meta.CharField(maxlength=1, choices=GENDER_CHOICES)
+
``core``
For objects that are edited inline to a related object.