Foreign key set template

53 views
Skip to first unread message

jorr...@gmail.com

unread,
Sep 22, 2016, 7:09:27 AM9/22/16
to Django users
I have a question about using model.foreignkey_set in Django templates. I was trying to use model.foreignkey_set to determine if there were any foreign keys for this model, but it appears that model.foreignkey_set returns something different than model.foreignkey_set.all - why is that? Shouldn't both return None if there are no foreign keys?

Just curious :)

Tim Graham

unread,
Sep 22, 2016, 11:38:31 AM9/22/16
to Django users
model.foreignkey_set returns a manager while model.foreignkey_set.all returns a QuerySet.

https://docs.djangoproject.com/en/stable/topics/db/queries/#following-relationships-backward
Reply all
Reply to author
Forward
0 new messages