django-model-utils
django-model-utils copied to clipboard
what about Choices.max_length ?
Looking at the documentation:
from model_utils import Choices
class Article(models.Model):
STATUS = Choices('draft', 'published')
status = models.CharField(choices=STATUS, default=STATUS.draft, max_length=20)
Wouldn't it be better to have something like:
status = models.CharField(choices=STATUS, default=STATUS.draft, max_length=STATUS.max_length)
That is, Choices can provide a method for figuring out the length of the longest choice. This way a little bit less thinking is required when you need to come up with the right length.