[Django]-Django Model API reverse lookup of many to many relationship through intermediary table

1๐Ÿ‘

โœ…

I was trying to evaluate a query set object, not the object itself. Executing a get on the query set and then a lookup of the relation set worked fine. Iโ€™m changing to community wiki and leaving this here just incase someone else is as stupid as I was.

A working example:

resident = Resident.objects.filter(name='Johnny')
resident.ssa_set.all() # fail
resident = resident.get() # will fail if more than one returned by filter
resident.ssa_set.all() # works, since we're operating on an instance, not a queryset
๐Ÿ‘คJosh Smeaton

Leave a comment