Django: traversing OneToOneField relationships, accessing `user` field of model - NameError
Solution 1:
The documentation on query lookups that span relationships is pretty informative. The thing to realize is that it's a standard function, so the left-hand side must always be a single keyword, not an expression. To enable this, use the double-underscore syntax:
Teacher.objects.filter(user__profile__organisation=request.user.profile.organisation, user__is_active = True)
Also note it's a single =
- again, it's a function invocation, not an expression.