Duplicating model instances and their related objects in Django / Algorithm for recusrively duplicating an object

后端 未结 17 1007
名媛妹妹
名媛妹妹 2020-11-29 01:04

I\'ve models for Books, Chapters and Pages. They are all written by a User:

from django.db import models
         


        
17条回答
  •  借酒劲吻你
    2020-11-29 01:41

    I haven't tried it in django but python's deepcopy might just work for you

    EDIT:

    You can define custom copy behavior for your models if you implement functions:

    __copy__() and __deepcopy__()
    

提交回复
热议问题