On Mar 17, 9:34 pm, Alastair Campbell <ala...@gmail.com> wrote:
> On Wed, Mar 17, 2010 at 7:02 PM, Dennis Kaarsemaker
>
> <den...@kaarsemaker.net> wrote:
> > In the view function, you could add an attribute (say, instance :-)) to
> > each form in the formset. That to me is a better way than doing weird
> > magic in a template.
>
> You're probably right, but I couldn't work that out for 
> formsets:http://dpaste.com/172317/
>
> Is there a standard programming pattern for matching up two loops?
> (I'm not a programmer by trade.)
>

Yes. Return pairs like [{'form': form1, 'instance': instance1}, ...]
and iterate on the template.

{% for pair in items %}
   <h1>{{ pair.instance.whatever }}</h1>
   <table>{{ pair.form }}</table>
{% endfor %}

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to