我有一个三级模型继承:
class Node(models.Model):
# all node fields are here
class QuestionNode(Node):
# all user-input-related fields are here
class RequestContactNode(QuestionNode):
# all fields specific for this request type are here
现在,我可以像这样复制QuestionNode
对象:
>>> from nodes.models import QuestionNode, RequestContactNode
>>> qnode = QuestionNode.objects.create(name='q', position=1)
>>> print(qnode.pk)
1240
>>> qnode.pk, qnode.id = None, None
>>> qnode.save()
>>> print(qnode.pk)
1241
但这不适用于RequestContactNode
,这是下一级继承:
>>> rcnode = RequestContactNode.objects.create(name='q', position=1,
... request_button_text='Share my number')
>>> print(rcnode.pk)
1242
>>> rcnode.pk, rcnode.id = None, None
>>> rcnode.save()
>>> print(rcnode.pk)
1242
为什么会这样,是否有解决方法?