Where developers save choice options in Django?

54 Views Asked by At

For example i have a choice

COLORS = (
    ('red', 'Red'),
    ('blue', 'Blue'),
    ('yellow', 'Yellow'),
) 

Should i create a model like:

class Color(models.Model):
    color = models.CharField(...)

and create some color instances in django-admin or i need to declare CHOICE(above), where i save all colors(even if there are many colors)?

1

There are 1 best solutions below

2
On BEST ANSWER

Let's say you need to make a model product and this model has multiple colors. In this case you need to create a model for color.

In case every product has one color you can use choice.