class Proposta(models.Model):
descrizione = models.TextField()
titolo = models.CharField(max_length=200)
richiedibile = models.BooleanField(default=False)
inRichiesta = models.BooleanField(default=False)
archiviata = models.BooleanField(default=False)
# tesi or AP
tipologia = models.CharField(max_length=50)
I want that the 'tipologia' field can have only two possible value: 'tesi' or 'AP'. In other words I want the field looks like a list in which user can choose the value he want.
Use the choices
argument in your Charfield:
TIPOLOGIA_CHOICES = [
("tesi", "tesi"),
("AP", "AP"),
]
class Proposta(models.Model):
...
tipologia = models.CharField(max_length=50, choices=TIPOLOGIA_CHOICES)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With