Somebody asked on #Django IRC: what is an easy way to get an objects primary key? I was shocked to hear he couldn’t find it on google.. and I guess it’s true. This is probably the very first stepping stone in learning Django.
I say: Do the Django Tutorials, they are short, well written, and fun!
Besides, its got a hassle-free return policy (90 days).
object_instance.id = your primary key
Wait… I was wrong. here’s an update from SmileyChris:
Actually, object_instance.pk would be more correct. “id” is just the default primary key field, whereas “pk” is an alias to the field which is defined as the primary key.