模型示例
class Example(Stat):
numeric = models.IntegerField(...)
date = models.DateField( auto_now_add=True,...) #auto_now_add=True was the problem
class Meta:
unique_together = ('numeric','date')
)
如果72和‘2011-08-07’已经存储
Example.object.get_or_create(numeric=72,date='2011-08-07')
加薪
django.db.utils.IntegrityError: (1062, "Duplicate entry '72-2011-08-07'
the question is why get_or_create
加薪 the IntegrityError
, thats the idea of using
get_or_create
.
不确定这是不是个漏洞,我开了张https://code.djangoproject.com/ticket/16587元的票