Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
734 views
in Technique[技术] by (71.8m points)

django model 如何唯一且可为空

需求想使accessBatch字段,唯一且可为空。

models.py
class Test(models.Model):
    order = models.CharField(max_length=20, verbose_name=u'订单')
    accessBatch = models.CharField(max_length=20, verbose_name=u'进厂编号', unique=True, blank=True, null=True, default=None)

目前用的是上述的方法,但是空值提交后会报错。
虽然刷新后是修改成功了。
但是每次提交总会报错,不知道有什么办法解决。

备注:
百度到的结果。
看不太懂。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...