On Mon, 2006-10-02 at 16:51 -0700, carlwenrich wrote:
[...]
> def admin_wslots(request):
>       global venue
>       global vslot
>       global week
>       global wslot
>       global day

You *really* don't want to use globals here. There doesn't appear to be
any need and it's going to cause lots of problems (almost impossible to
reproduce bugs, for example) in a multi-threaded environment.

>       try:
>               wslot = get_object_or_404(WeekSlot, pk=request.POST['wslot'])
>       except:
>               wslots = WeekSlot.objects.filter(week=week.id)
>               return render_to_response('sched/admin_vslots.html', {
>                       'vslot': vslot,
>                       'week': week,
>                       'wslots': wslots,
>                       'error_message': 'You must select a day.'
>                       })
>       else:
>               day = Day.objects.get(id=wslot.day_id)
>               dslots = DaySlot.objects.filter(day=day.id)
>               return render_to_response('sched/admin_wslots.html', {
>                       'week': week,
>                       'wslot': wslot,
>                       'dslots': dslots,
>               })
> 
> --- Here's the form part of the template:
> 
> <form action='/sched/admin_dslots/' method='post'>
> 
> {% for dslot in dslots %}
> <input type='checkbox' name='dslot' id='dslot{{ forloop.counter }}'
> value='{{ dslot.id }}' checked='{{ dslot.taken }}'>
> <label for='dslot{{ forloop.counter }}'>{{ dslot.slot }}</label><br>
> {% endfor %}
> 
> <p><input type='submit' value='Submit'></p>
> </form>
> When I go through the standard admin interface, the checkboxes show up
> correctly (2 checked, 4 unchecked).
> When I bring up the (template) form, all 6 checkboxes show up checked.

It's an HTML issue: if you specify the "checked" attribute is set to
anything for a checkbox input element, it is considered to be "on". You
need to leave off the checked attribute when dslot.taken is false.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to