dspjm
dspjm

Reputation: 5840

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

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?

Upvotes: 37

Views: 18881

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798556

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.

Upvotes: 49

Related Questions