You can't do indirect variable references like this in Django's
templating language. The reasoning is that it ends up complicating the
template structure when you wander down that path. Instead, factor it
out into a template tag (that can be passed the current context, so it
will have access to the forloop counter) or set up the data structures
you pass to your view a bit differently so that you can loop over the
forms and the products simultaneously (that is, pull apart the formset
forms and zip them together with the product entries in the view).
Usually the second approach works a bit more nicely, but either is
possible.
Regards,
Malcolm
You don't loop through two structures at once in your template. I
suggested you change the datastructures in your (Python) view so that
you only loop through one data structure that happens to be a sequence
of pairs. Each pair contains on of the forms and one of the queryset
members. You do all the data structure munging at the Python level, not
at the template level.
Regards,
Malcolm