I have a Django field, which I use mainly as an enumeration for notification settings.
Now I configured it like this:
class MyModel(models.Model):
EVERY_TIME = 'every'; WEEKLY = 'weekly'; NEVER = 'never'
NOTIFICATION_CHOICES = ((EVERY_TIME, "Every time"), (WEEKLY, "Weekly"), (NEVER, "Never"))
notification_preferences = models.CharField(choices=NOTIFICATION_CHOICES, default=EVERY_TIME, max_length=10)
I know that usually this kind of enumeration should be configured as models.IntegerField, rather than CharField, but since the front-end uses Angular and all the data is transmitted through the API, it seems to me that it can provide a little more useful information for the front-end for receiving 'weekly', rather than 2, eg.
Is it bad practice to use CharFieldas an enumeration? If so, is my use case small enough for it to be unimportant, or is there something I am missing to change it?
source
share