【发布时间】:2019-08-18 18:30:36
【问题描述】:
我有一个具有动态选择的模型字符域
class MachineChoices(object):
def get_machine_choices(self):
# call external service to get a full list of machines
...
def __iter__(self):
yield from self.get_machine_choices()
class ExceptionMapping(models.Model):
machine_id = models.IntegerField(null=True, blank=True, choices=MachineChoices())
我的问题是,当我运行 makemigrations 时,它会为包含所有选项的字段生成迁移。
如果没有如此巨大的迁移,我该如何解决这个问题。每次运行 makemigrations 时手动删除此迁移是一件很痛苦的事情。
请注意: 我问为什么会这样,因为我已经问过before。
【问题讨论】:
标签: django