In my Django models.py file, I have a variable ColourChoices = ((0, "GREEN"), (1, "YELLOW"), (2, "RED"), (3, "GREY"))
where in the same file, ColourChoices is used in class
class Rainbow(models.Model):
colour = models.IntegerField(choices=ColourChoices)
I was wondering if there is a viable way to create a view for ColourChoices (i.e. some JSON endpoint), such that you can get all the existing values for it (GREEN, YELLOW, RED, GREY) without creating a new table in the underlying database and adding those values to it? That is, in such a way that if I were to add a new colour (e.g. BLUE), or remove one colour from the choices, that doing it once in the code would do the trick (i.e. change what you see in the view).