On Apr 18, 3:23 pm, google torp <[email protected]> wrote:
> Hi.
> Normally, what you are doing would work, initializing the form
> with request.POST. However the way you have constructed
> your form, you need have a poll object as well. Not only that
> but it should of cause be the poll that the post data is associated
> to.
> Then you could do it like this
> form = PollForm(the_right_poll, request.POST)
>
> ~Jakob

Thanks for pointing me in the right direction Jakob.  I've changed my
view adding in 'the_right_poll'.  Works well, but I still have some
improvements to make. Thank you.

#views.py
def do_the_poll(request):
    if request.method == "POST":
        polls = get_list_or_404(Poll)
        for poll in polls:
            form = PollForm(poll, request.POST)
            if form.is_valid():
                choice = form.cleaned_data[poll.question]
                choice.votes += 1
                choice.save()
        return redirect('/mediapoll/')
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to