Recovery of the Django model gives an erroneous error

advertisements

I have a template that has a button that posts just the button's name to a view which has the following code:

if request.POST:
    a = request.POST
    name = mymodel.objects.get(id = a )[0]
        return HttpResponse(name)

request.POST has the name of the button that submitted the post. THE error is: int() argument must be a string or a number, not 'QueryDict'

However, when I do: a = request.POST['name], django raises a no 'name' in post error. How do I fix this?


This returns a QueryDict (similar to a python dictionary) with the data in it request.POST

anyway

request.POST['name']

should work. I would say theres no key 'name' in it. pearhaps it is called 'id_name' or something like that.

Have a look a the content of the query dict with a debugger or with a print statement:

print request.POST