Wagtail: How can I copy a page instance in wagtail with all its property and method
<p>I have a CoursePage model in Wagtail site.</p>

<pre><code>class CoursePage(Page):
    .....
    institute = models.ForeignKey(Institute)
    .....
</code></pre>

<p>I have a django models ForeignKey field in it named <em>institute</em></p>

<p>I want to make a copy of its instance programmatically so that the newly created instance <strong>institute</strong> field can be modified.</p>

<p>I tried django approach of copying model instance, that is:</p>

<pre><code>course = CoursePage.objects.all()[0]
course.pk = None
course.save()
</code></pre>

<p>But it doesnot work out.
It only works with the model inherited with django <em>models.Model</em>. but not with the model inherited with <strong>Page</strong></p>

<p>The <code>Page</code> model implements a <code>copy</code> method to do this:</p>

<pre><code>def copy(self, recursive=False, to=None, update_attrs=None,
         copy_revisions=True, keep_live=True, user=None):
</code></pre>

<p>The parameters it accepts are:</p>

<ul>
<li><code>recursive</code> - if true, copies child pages as well</li>
<li><code>to</code> - the page to create the new copy under (defaults to creating a sibling of the existing page)</li>
<li><code>update_attrs</code> - a dict of fields to update while copying, such as <code>{'institute': other_institute}</code></li>
<li><code>copy_revisions</code> - whether to copy revision history</li>
<li><code>keep_live</code> - whether to copy the 'live' status</li>
<li><code>user</code> - the owner of the new page, for permission purposes</li>
</ul>

python django-models wagtail