[Django]-Get model instance id from foreign key field without loading object

4👍

The first one – somealert.contact.pk – will get the Contact object. The second – somealert.contact_id – won’t.

You can verify this in the shell by looking at the contents of django.db.connection.queries.

Leave a comment