Kaydet (Commit) 8da17bac authored tarafından Adrian Holovaty's avatar Adrian Holovaty

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
üst 36f1aef5
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment