[Fixed]-Formset populated by wrong data – Django 1.8

1👍

This depends on your model.

formset = ImageFormSet(queryset=ProductImage.objects.all()) # possible wrong queryset

This is indeed the wrong queryset. You should do something like:

queryset=ProductImage.objects.filter(product_id = pk)

if you gave the product_image field a related_name than you could do

queryset=instance.related_product_images

https://docs.djangoproject.com/en/1.8/ref/models/fields/#django.db.models.ForeignKey.related_name

Leave a comment