djangosnippets.org: Latest snippets tagged with 'clone'https://djangosnippets.org/tags/clone/2008-12-31T02:55:06.661285-06:00Clone model mixin
2008-12-31T02:55:06.661285-06:00zakjhttps://djangosnippets.org/snippets/1271/<p>Add this as a superclass of any Django model to allow making copies of instances of that model:</p>
<pre><code>class Entry(models.Model, CloneableMixin):
[...]
e = Entry.objects.get(...)
e_clone = e.clone()
e_clone.title = 'Cloned Entry'
e.save()
</code></pre>
<p>The new object is saved during the clone process and ManyToMany relations are copied as well.</p>
Freely redistributableClone method for Django models
2008-07-22T14:10:29.505316-05:00nsidehttps://djangosnippets.org/snippets/904/<p>Add this method to any model to make it clonable.</p>
Freely redistributable