On wo, 2010-03-17 at 09:34 +0000, Alastair Campbell wrote:
> On Tue, Mar 16, 2010 at 7:46 PM, Dennis Kaarsemaker wrote:
> > Each ModelForm has an instance attribute, so you can use
> > {{ form.instance.whatever }}
> 
> Hi Dennis,
> 
> Unfortunately it is not a model form. The form creates an "entry",
> which is de-normalised data taken from the person (member) details and
> the event details.
> 
> The closest I've gotten so far is to use something like this in the
> formset loop:
> {% for member in members %}
> {% ifequal member.sail_number form.sail_number.data %}
> {{ member.name}}
> {% endifequal %}
> {% endfor %}
> 
> Unfortunately not all members have sail numbers, so I'll try passing
> initial data for member.id through to the form as a better match.
> 
> Unless there's a better way to do it?

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.

> Also, is there a danger to using form.something.data? It isn't in the
> docs, but I found it as a possible way of matching the form against
> the object values.

Maybe you can run into user input creepiness, such as someone overriding
the field in the post request and being able to see data from other
objects. Not sure how realistic that is.

-- 
Dennis K.

The universe tends towards maximum irony. Don't push it.

-- 
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