Changeset 1570
- Timestamp:
- 12/08/05 19:53:30 (3 years ago)
- Files:
-
- django/trunk/docs/model-api.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/docs/model-api.txt
r1426 r1570 104 104 The first element in each tuple is the actual value to be stored. The 105 105 second element is the human-readable name for the option. 106 107 Define the choices list **outside** of your model class, not inside it. 108 For example, this is not valid:: 109 110 class Foo(meta.Model): 111 GENDER_CHOICES = ( 112 ('M', 'Male'), 113 ('F', 'Female'), 114 ) 115 gender = meta.CharField(maxlength=1, choices=GENDER_CHOICES) 116 117 But this is valid:: 118 119 GENDER_CHOICES = ( 120 ('M', 'Male'), 121 ('F', 'Female'), 122 ) 123 class Foo(meta.Model): 124 gender = meta.CharField(maxlength=1, choices=GENDER_CHOICES) 106 125 107 126 ``core``
