I'm trying to make a field with limited choices:
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)
However, when I was trying to insert content violating the rules, it succeeded without any error or warning messages (with "manage.py shell"). It seems any text of any length can be put into this field. I'm using SQLite3 as the backend.
Is it supposed to be like that? Or if I missed something?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…