Relative Content

Tag Archive for pythondjangodjango-models

Will a dynamic list of choices in a Django model evaluate when the model is migrated or when a user tries to select a choice for a model?

Code Let’s say I have the following model: class Course(models.Model): title = models.CharField(max_length=48) YEAR_CHOICES = [(r, r) for r in range( datetime.date.today().year-1, datetime.date.today().year+2 ) ] year = models.IntegerField(_(‘year’), choices=YEAR_CHOICES) Question Will the datetime.date.today() statements be evaluated right when the model is migrated, or will they be evaluated whenever the user accesses a form to set […]