[Answered ]-Django – Follow a backward ForeignKey and then a ForeignKey (query)

2👍

Because all() returns a queryset, which is a collection of items; theplace is an attribute on an individual Step, not on the collection.

The way to do this type of query is to start from the class you want to retrieve, and follow the relationships within the query using the double-underscore syntax. So:

Picture.objects.filter(theplace__step__trip=selectedtrip)

Leave a comment