1👍
✅
You are trying to query a reverse relation which is documented here.
If a model has a ForeignKey, instances of the foreign-key model will
have access to a Manager that returns all instances of the first
model. By default, this Manager is named FOO_set, where FOO is the
source model name, lowercased. This Manager returns QuerySets, which
can be filtered and manipulated as described in the “Retrieving
objects” section above.
user = User.objects.get(pk=2)
user_hosts = user.hostname_set.all()
👤arie
Source:stackexchange.com