Re: Getting values from a Drop Down menu

2006-12-16 Thread gordyt
Howdy Matt! Here is a small, complete working sample. When you initially load the page it just displays the choices and prompts you to select a value and click submit. When you submit it, it redisplays the form and then displays what choice you selected. urls.py: from

Re: Getting values from a Drop Down menu

2006-12-16 Thread [EMAIL PROTECTED]
Is it still giving the same error after adding the name? Or is it a different error now? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: Getting values from a Drop Down menu

2006-12-15 Thread Joseph Heck
For debugging, start by seeing what *is* in the POST dict that you get back from the request. Super simple - just print it out and see what's in there. That might give you a clue how it's interpreting it when it comes back... -joe On 12/15/06, MattW <[EMAIL PROTECTED]> wrote: > > > Sorry, should

Re: Getting values from a Drop Down menu

2006-12-15 Thread MattW
Sorry, should have made it clear on my second post in response to Massimiliano. He suggested this, and so I altered the code so it now reads: def ansQuestion(request): q = get_object_or_404(Question) answer = request.POST["answer"] A Since (at least) two people have now suggested

Re: Getting values from a Drop Down menu

2006-12-15 Thread Nathan R. Yergler
a bit stuck on getting the values from a Drop Down menu. > > I have a method in my views.py file which starts: > > def ansQuestion(request): > q = get_object_or_404(Question) > answer = request.POST['value'] > > and the template reads: > > > > A >

Re: Getting values from a Drop Down menu

2006-12-15 Thread Joseph Heck
You need to tell the form what the "name" of the name value pair you're using it. SInce you're trying to look it up in your code as post['answer'] (at least based on the error you posted), that should be the name that you use in the HTML input tag . On 12/15/06, MattW <[EMAIL PROTECTED]>

Re: Getting values from a Drop Down menu

2006-12-15 Thread MattW
Ok - sorry, could you (briefly) explain what you mean? Thanks, Matt --~--~-~--~~~---~--~~ 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

Re: Getting values from a drop-down menu

2006-12-15 Thread Joseph Heck
Where are you setting "answer" in the HTML form? It should be in there as a name="" element entry of the select tag... -joe On 12/15/06, MattW <[EMAIL PROTECTED]> wrote: > > > Dear Massimiliano, > > Thanks for that; still doesn't work, I'm afraid. > > The error is: > > MultiValueDictKeyError at

Re: Getting values from a drop-down menu

2006-12-15 Thread MattW
Dear Massimiliano, Thanks for that; still doesn't work, I'm afraid. The error is: MultiValueDictKeyError at /mcq/ansQuestion/ "Key 'answer' not found in " Request Method: GET Request URL:http://localhost:8000/mcq/ansQuestion/ Exception Type: MultiValueDictKeyError Exception

Re: Getting values from a Drop Down menu

2006-12-15 Thread [EMAIL PROTECTED]
I think you need a name (and maybe ID) on your select box. --~--~-~--~~~---~--~~ 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

Getting values from a Drop Down menu

2006-12-15 Thread MattW
Dear All, A newbie with Django, but seem to be doing with some basics so far, but seem to be a bit stuck on getting the values from a Drop Down menu. I have a method in my views.py file which starts: def ansQuestion(request): q = get_object_or_404(Question) answer = request.POST['value

Re: Getting values from a drop-down menu

2006-12-13 Thread Massimiliano Ravelli
Matt Williams wrote: > > A > but I keep getting an error about an empty MultiValuedDict {}, which I > think means that I'm not getting the values back. Try: A ... and then read request.POST['letter'] Massimiliano --~--~-~--~~~---~--~~ You received this

Getting values from a drop-down menu

2006-12-13 Thread Matt Williams
Dear All, I'm a newbie with Django, and have what is probably a very simple question. I'm trying to get the values from an html drop-down form. I've got a form like this: A B C D E with a method in views.py: ansQuestion(request): q = get_object_or_404(Question) answer =