To do reverse lookup of foreign keys with Python Django, we can use the filter
method.
For instance, we write
def detail(request, venue_id):
venue = Event.objects.filter(venue__id=venue_id)
return render(request, 'venue-detail.html', {'venue': venue})
to look up the Event
objects by the venue_id
with filter
.
And then we render the values in the venue-detail.html.