Reputation: 34170
If there exists an old data of a model say ,
query=Emp.objects.filter(pk=profile.id)
Is there a easier way to copy the same values into the same model again..
Now that the id will be different so..
I have this requirement.
Thanks..
Upvotes: 1
Views: 298
Reputation: 25032
object = Emp.objects.get(pk=profile.id)
object.save(force_insert=True)
It's much more explicit then removing primary key's value. See also "forcing an insert or update" in Django documentation.
Upvotes: 7