Page copy now copies child objects

This commit is contained in:
Karl Hobley 2014-06-26 09:51:50 +01:00
parent 069406f86b
commit b9993a8c1e

View file

@ -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: