What's the difference between Model.id and Model.pk in django?

Question:

I saw the django documents use both sometimes? Are they identical? What’s the difference and where is the reference? I only see documentation of pk.

BTW, does django reference cover all the methods of its classes?

Asked By: dspjm

||

Answers:

pk is the attribute that contains the value of the primary key for the model. id is the name of the field created as a primary key by default if none is explicitly specified.

Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.