0
我想叫状态的自定义字段,这foreinkey是在另一个模型 阅读文档的https://docs.djangoproject.com/en/dev/howto/custom-model-fields/子类化Models.Charfield为自己的自定义模型字段
1class TransactionStateModelField(models.CharField):
description = 'What state is this transaction'
def __init__(self, *args, **kwargs):
kwargs['status'] = 'initiated' # additional options for status could be accepted and delivered
super(TransactionStateModelField, self).__init__(*args, **kwargs)
2:11:42 web.1 | File "/home/talisman/virt_env/tempilo/local/lib/python2.7/site-packages/Django-1.5.4-py2.7.egg/django/db/models/fields/__init__.py", line 626, in __init__
12:11:42 web.1 | super(CharField, self).__init__(*args, **kwargs)
12:11:42 web.1 | TypeError: __init__() got an unexpected keyword argument 'status'
我不知道如果我后去正确的方法, 基本上我想改变一个交易的状态,从发起>接受>交付> |取消