Updated docs re choices

[#284] [#314]
This commit is contained in:
Ross Lawley 2011-11-04 01:54:30 -07:00
parent bfdaae944d
commit 4c1509a62a

View File

@ -135,7 +135,28 @@ arguments can be set on all fields:
When True, use this field as a primary key for the collection. When True, use this field as a primary key for the collection.
:attr:`choices` (Default: None) :attr:`choices` (Default: None)
An iterable of choices to which the value of this field should be limited. An iterable (e.g. a list or tuple) of choices to which the value of this
field should be limited.
Can be either be a nested tuples of value (stored in mongo) and a
human readable key ::
SIZE = (('S', 'Small'),
('M', 'Medium'),
('L', 'Large'),
('XL', 'Extra Large'),
('XXL', 'Extra Extra Large'))
class Shirt(Document):
size = StringField(max_length=3, choices=SIZE)
Or a flat iterable just containing values ::
SIZE = ('S', 'M', 'L', 'XL', 'XXL')
class Shirt(Document):
size = StringField(max_length=3, choices=SIZE)
:attr:`help_text` (Default: None) :attr:`help_text` (Default: None)
Optional help text to output with the field - used by form libraries Optional help text to output with the field - used by form libraries