これは本当に単純なはずですが、頭がわかりません。単純な 1 文字の値を django モデル インスタンスに割り当てたいと考えています。私は何百万回もそれをしましたが、この場合はうまくいきません。
私のモデル.py
class MetaInformation(models.Model):
# part of the class profile ...
PROFILE_STATUS = (
('C', 'Claimed'),
('U', 'Unclaimed'),)
status = models.CharField(_('Profile'), max_length=1,
choices = PROFILE_STATUS,)
class Profile(MetaInformation):
# additional attributes
...
今、私はで実行していDjango shell
ます:
In [1]: a = Profile.objects.all()
In [2]: a[1].status
Out[2]: u'U'
In [3]: a[1].status = Profile.PROFILE_STATUS[0] # equal to 'C'
In [4]: a[1].save()
私は結果が
In [14]: a[1].status
Out[14]: u'C'
しかし、ジャンゴは戻ってきます
In [14]: a[1].status
Out[14]: u'U'
属性の保存が認識されない、またはエラー メッセージが表示されるのはなぜですか?