[Answered ]-Django for loop over list

2👍

The Location class should have fields or properties that give you the relevant ratings / comments / images. Then you can just pass a list of Locations to your template.

If Location is a Django model, then the ratings / comments / images should each have a ForeignKey that points to Location. In that case, Django will create properties on Location that point to the corresponding ratings / comments / images. Use related_name to choose the name of that property, otherwise Django will invent a name.

Leave a comment