【发布时间】:2012-01-18 16:01:23
【问题描述】:
我正在尝试创建一个选择有限的字段:
Action_Types=(
('0','foo'),
('1','bar'),
)
class Foo(models.Model):
myAction=models.CharField(max_length=1,choices=Action_Types)
def __unicode__(self):
return '%d %s'%(self.pk,self.myAction)
但是,当我尝试插入违反规则的内容时,它成功了,没有任何错误或警告消息(使用“manage.py shell”)。似乎任何长度的任何文本都可以放入此字段。我使用 SQLite3 作为后端。
应该是这样的吗?或者如果我错过了什么?
【问题讨论】:
标签: django sqlite model choice maxlength