I have a model like this:
class MyModel(models.Model):
DAYS = ((str(d), str(d)) for d in range(1, 29))
day1 = models.CharField('Day 1', max_length=3, null=True, blank=True, choices=DAYS)
day2 = models.CharField('Day 2', max_length=3, null=True, blank=True, choices=DAYS)
After it gets rendered I see that only field day1
has choice list, but day2
is empty. If I make another constant DAYS2
with the same definition and assign it to day2
- it works.
It seems Django modifies the source of choices
argument? I did not find it in the sources, but maybe I do something wrong? Is it a known limitation?
I can use workaround of applying deepcopy
on DAYS
. But I do not think it is good style. Is there another way?