2👍
obj.pk
refers to the object property which acts as an alias to the primary key.
See http://docs.djangoproject.com/en/dev/ref/models/instances/#the-pk-property for details.
As for how to google for it, I stumbled upon that reference by google for “+django Model.pk” since obj if of class models.Model
.
In fact, When looking for django related docs, the easiest would be to use the search box in the http://docs.djangoproject.com site. If you really want to use google, include +site:docs.djangoproject.com
to your search string, e.g “pk +site:docs.djangoproject.com”.
0👍
The usability of ‘pk’ field is that you can use someone other’s model which has the primary key field called other than ‘id’. In other words the ‘pk’ field gives you a flexibility to use model’s primary key not knowing what this key actually is.
- [Answered ]-How to create Django model field to store users related to the model?
- [Answered ]-Django how to count 10 most occurrences
- [Answered ]-Template not found with Django on Heroku