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 django.conf.urls.defaults
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 django-users@goog
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
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 tha
Don't you need to specify a name for the select element? If you're
trying to get the selection with the key "value", I think you need to do:
.
.
.
NRY
MattW wrote:
> 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
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]> wr
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 unsu
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 /
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
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 fro
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'
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
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 = requ
13 matches
Mail list logo