[Answer]-Django/Python models – multifield options

1👍

The proper way is to use the choices argument for a particular field. Documentation here

Thus:

class AnObject(models.Models)
    SHAPE_CHOICES = (
        (CIRCLE, 'Circle'),
        (TRIANGLE, 'Triangle'),
        (SQUARE, 'Square'),
    )
    shape = models.CharField(max_length=8,
                             choices=SHAPE_CHOICES,
                             default=CIRCLE)
👤Alex

Leave a comment