To clone a Python Django model instance object and save it to the database, we can use the get
method.
For instance, we write
obj = Foo.objects.get(pk=<some_existing_pk>)
obj.pk = None
obj.save()
to get the object with Foo.objects.get
.
And then we set pk
to None
.
Finally, we call save
to save the data.