--- Here's the model:

class DaySlot(models.Model):
        slot = models.TimeField(core=True)
        taken = models.BooleanField(core=True)
        day = models.ForeignKey(Day, edit_inline=models.TABULAR,
num_in_admin=6)

        def __str__(self):
                return str(self.slot)

--- Here's the view:

def admin_wslots(request):
        global venue
        global vslot
        global week
        global wslot
        global day
        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>

--- Here's the initialization:

INSERT INTO sched_day (name) VALUES ('Eight To Five');
INSERT INTO sched_dayslot (slot, taken, day_id) VALUES ('08:00',
'True', '1');
INSERT INTO sched_dayslot (slot, taken, day_id) VALUES ('09:30',
'True', '1');
INSERT INTO sched_dayslot (slot, taken, day_id) VALUES ('11:00',
'False', '1');
INSERT INTO sched_dayslot (slot, taken, day_id) VALUES ('12:30',
'False', '1');
INSERT INTO sched_dayslot (slot, taken, day_id) VALUES ('02:00',
'False', '1');
INSERT INTO sched_dayslot (slot, taken, day_id) VALUES ('03:30',
'False', '1');

---

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.

Any ideas?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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