mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-12 01:03:11 +00:00
Minor cleanup
This commit is contained in:
parent
74d1555ac1
commit
98effcb4d7
1 changed files with 8 additions and 9 deletions
|
|
@ -573,16 +573,15 @@ class Page(MP_Node, ClusterableModel, Indexed):
|
|||
page_copy = self.add_sibling(instance=page_copy)
|
||||
|
||||
# Copy child objects
|
||||
if hasattr(self._meta, 'child_relations'):
|
||||
for child_relation in self._meta.child_relations:
|
||||
parental_key_name = child_relation.field.attname
|
||||
child_objects = getattr(self, child_relation.get_accessor_name(), None)
|
||||
for child_relation in getattr(self._meta, 'child_relations', []):
|
||||
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()
|
||||
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