On Jan 6, 12:20 pm, Max <adles...@gmail.com> wrote:
> Hello,
>
> Using the tutorial for detail.view, I changed the radio button to a
> drop down.  I kept the view the same as the tutorial.  
> Seehttp://dpaste.com/106018/
>
> When I select the choice on the drop down, I receive the error saying
> I didn't make a choice.   I have a mistake in either the drop down
> code or I need to change the view.
>
> Can someone help?
>
> Thanks,
>
> Max

The problem is in your template. Specifically, line 7:
<select id="{{ choice.id }}">
At this point, you don't have a variable called 'choice', as you don't
set that until the for loop in the next line. If you look at your
rendered HTML (do View Source within the browser), you'll see that
this will probably just give you this markup:
<select id="">
So, obviously, there's nothing to link the selected value with any key
in the POST dictionary.

Instead, you probably want this:
<select id='id_choice' name='choice'>
Note that you should really set a name as well as the id - that's the
best way of referring to form fields.

However, I have to say that the tutorial doesn't really give you the
best way of doing things here. Django has a great built-in forms
framework, which allows you to do the same thing in far less code and
much more 'Djangonically' (is that the right word?) and this bypasses
it completely. Unfortunately, the tutorial doesn't cover the forms
framework - although it is very well documented here:
http://docs.djangoproject.com/en/dev/topics/forms/

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