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

后端 未结 17 1033
名媛妹妹
名媛妹妹 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:31

    Using the CollectedObjects snippet above no longer works but can be done with the following modification:

    from django.contrib.admin.util import NestedObjects
    from django.db import DEFAULT_DB_ALIAS
    

    and

    collector = NestedObjects(using=DEFAULT_DB_ALIAS)
    

    instead of CollectorObjects

提交回复
热议问题