[Answered ]-Access Related Models

2👍

This is answered in full in the documentation on making queries.

Extension.objects.filter(user__department__name='my department')
PhonePIN.objects.filter(user__department__name='my department')

or, if you already have a Department object:

Extension.objects.filter(user__department=my_department)
PhonePIN.objects.filter(user__department=my_department)

which will save you a JOIN.

Leave a comment