7đź‘Ť
âś…
You should use ModelForms.
(updated)
1) In your models.py, you define the choices:
CELLSERPRO_CHOICES = (
('ver', 'Verizon'),
('att', 'AT&T'),
('tmo', 'T-Mobile'),
('spr', 'Sprint'),
)
2) In your models.py, inside “class Author”, you define the cellSerpro field like this:
class Author(models.Model):
cellSerpro = models.CharField(max_length=3, choices=CELLSERPRO_CHOICES)
3) In your forms.py (create it if you don’t have it), you define a form like this:
class AuthorForm(ModelForm):
class Meta:
model = Author
4) And then, just use that form in a view, as you would with any other form.
👤David Arcos
Source:stackexchange.com