36

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?

thumbtackthief
  • 6,093
  • 10
  • 41
  • 87
dspjm
  • 5,473
  • 6
  • 41
  • 62
  • 2
    DUPLICATE : http://stackoverflow.com/questions/2165865/django-queries-id-vs-pk – Priyank Patel Mar 12 '14 at 08:38
  • @PriyankPatel I saw that question too, I don't think they are duplicate. – dspjm Mar 12 '14 at 08:40
  • I'm working through the tutorials now and was confused by this too. For now I'm just going to ignore it and worry about the difference when there is a practical reason to. This comment is just to help me remember not to forget to look into it down the road. They say taking an active part in your learning makes it more effective. –  Jan 29 '17 at 04:28
  • @dspjm Why are they not duplicate? I think they are. – dfrankow Mar 16 '23 at 00:42

1 Answers1

47

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.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358