如何动态设置django的model field的默认值
展开全部
动态设置django的model field的默认值:
1
2
3
4
5
6
7
8
def get_default_ignore_fort():
cur_env =ENV.upper()
return any(i in cur_env for i in ('UAT', 'FAT'))
class Application(TimestampedModel):
name = models.CharField(max_length=255, null=True)
ignore_fort = models.BooleanField(default=get_default_ignore_fort)
1
2
3
4
5
6
7
8
def get_default_ignore_fort():
cur_env =ENV.upper()
return any(i in cur_env for i in ('UAT', 'FAT'))
class Application(TimestampedModel):
name = models.CharField(max_length=255, null=True)
ignore_fort = models.BooleanField(default=get_default_ignore_fort)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询