So I have two models: Car and Picture. a car may have multiple pictures.
Now I want to use a list view to display all the cars along with one picture for each car, can someone tell me how can I do that? Below is my code
# models.py
class Car(models.Model):
name = models.CharField(max_length=100)
class Picture(models.Model):
car = models.ForeignKey(Car,related_name='pictures')
picture = models.ImageField()
# views.py
class CarList(ListView):
model = Car
car.picture_set.all
? – Stickup