0

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)?

dan1st
  • 12,568
  • 8
  • 34
  • 67
Ihor
  • 97
  • 10

1 Answers1

1

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.

Mohamed Hamza
  • 945
  • 1
  • 5
  • 15
  • But is it a right way to create a list of colors if i have for example 30 colors or even more and i'll filter by colors these products later? – Ihor Jul 11 '21 at 14:39
  • No, you don't have to do that, if you have a lot of colors just create model for them. – Mohamed Hamza Jul 11 '21 at 14:44