[Answered ]-Django Reverse Lookups of Foreign Keys is not working

1👍

You set the related_name=… parameter [Django-doc] to 'domains', hence you look up the reverse with:

tenant = Client.objects.all()
for t in tenant:
    for i in t.domains.all():
        print(i)

Note: There is no need to specify db_index=True [Django-doc] for a ForeignKey [Django-doc]. As the documentation specifies: A database index is automatically created on the ForeignKey..

Leave a comment