mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-12 01:03:11 +00:00
Page copy now copies child objects
This commit is contained in:
parent
069406f86b
commit
b9993a8c1e
1 changed files with 8 additions and 1 deletions
|
|
@ -575,7 +575,14 @@ class Page(MP_Node, ClusterableModel, Indexed):
|
|||
# Copy child objects
|
||||
if hasattr(self._meta, 'child_relations'):
|
||||
for child_relation in self._meta.child_relations:
|
||||
pass
|
||||
parental_key_name = child_relation.field.attname
|
||||
child_objects = getattr(self, child_relation.get_accessor_name(), None)
|
||||
|
||||
if child_objects:
|
||||
for child_object in child_objects.all():
|
||||
child_object.pk = None
|
||||
setattr(child_object, parental_key_name, page_copy.id)
|
||||
child_object.save()
|
||||
|
||||
# Copy child pages
|
||||
if recursive:
|
||||
|
|
|
|||
Loading…
Reference in a new issue