On Mar 15, 3:42 am, django_jedi <pemaq...@gmail.com> wrote:
> Hi All,
>
> Pardon a newbie.
>
> I'm building a form that will display workshop selections a person has
> made.  They'll be able to update their selections using this form.
>
> Selections are represented by radio buttons; I'm trying to make a
> radio button the "checked" option as I run through a loop, and nothing
> I try seems to work.  I'm using {% ifequal %} primarily:
>
> TEMPLATE:
> ---------------
> ...
> {% for object in workshops %}
>    <input type="radio" ... value="{{ object.id }}" ... {% ifequal
> object.id selections.groupA %} checked {% endifequal %}  />
> ...
> {% endfor %}
> ...
>
> VIEW:
> ---------
> ...
> workshops = [a queryset]
> selections = [a different queryset]
>
> return render_to_response('workshops/form.html',
>                 {
>                 ...
>                'selections': selections,
>                 'workshops': workshops,
>                 ...
>                 },
>                 context_instance=RequestContext(request))
>
> I can't seem to get the value of selections.groupA while inside the
> for loop; I can get it just fine anywhere else in the template.
>
> I may be barking up the wrong tree; I've scoured the Internet and the
> documentation to no avail.
>
> I would appreciate it if someone can point out what I'm missing and/or
> suggest an alternative.
>
> TIA

Assuming that 'groupA' is a model field, there's no such property as
'selections.groupA', because as you've stated, selections is a
queryset - ie a collection of model instances, not a single one.

However in general you'd be better off using Django's forms framework,
which outputs fields for you with all the correct attributes selected.
--
DR.

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