Django: copy model instance

To copy model instance, replacing pk value is the easiest way.

obj = Foo.objects.get(pk="foo")
obj.pk = "bar"
obj.save()

http://stackoverflow.com/questions/4733609/how-do-i-clone-a-django-model-instance-object-and-save-it-to-the-database

Leave a Reply

Your email address will not be published. Required fields are marked *