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 aForeignKey
[Django-doc]. As the documentation specifies: A database index is automatically created on the ForeignKey..
Source:stackexchange.com