Sanity for the django choices functionality.
Project description
Documentation is a work in progress.
Django choices provides a declarative way of using the choices option on django fields.
Basic Usage
To start you create a choices class in choices.py or const.py (I prefer const.py). Then you point the choices property to the choices attribute of the new class. Django will be able to use the choices and you will be able to access the values by name. For example:
# In choices.py from djchoices import DjangoChoices, ChoiceItem class PersonType(DjangoChoices): Customer = ChoiceItem("C") Employee = ChoiceItem("E") Groundhog = ChoiceItem("G") # In models.py class Person(models.Model): name = models.CharField(max_length=32) type = models.CharField(max_length=1, choices=choices.PersonType.choices) # In other code Person.create(name="Phil", type=PersonType.Groundhog)
License
Licensed under the MIT License.
Souce Code
The source code can be found on github.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-choices-1.1.0.tar.gz
(3.1 kB
view hashes)