Reputation: 22083
I am aware that pk
is preferable because id
is builtins.They are identical.
However, reference to copy instances which use inheritance, it's not complicated to distinguish them:
In the official tutorial doc
#Due to how inheritance works, you have to set both pk and id to None:
django_blog.pk = None
django_blog.id = None
django_blog.save() # django_blog.pk == 4
There, pk
is definitely not identical to id
How to understand it?
Upvotes: 0
Views: 43