所以我已经定义了一些字段作为选择:
class MyModel(models.Model):
# Text language.
ENGLISH = 'eng'
FRENCH = 'fr'
LANGUAGES_CHOICES = [
(ENGLISH, 'English'),
(FRENCH, 'French'),
]
language = models.CharField(
max_length=max(len(language) for language in LANGUAGES_CHOICES),
choices=LANGUAGES_CHOICES,
blank=False,
null=True)
Run Code Online (Sandbox Code Playgroud)
但是,我可以做到MyModel(language='hurhurhur').save()没有任何错误或投诉.我错过了什么?