I'm a Django newbie and I'm trying to do some minor tests with POST methods
(I need an automated/scriptable way to get data into my Django database).
Using the following code

@csrf_exempt
def posttest(request):
        z=request.POST.get('data', 'no data')
        html="<html><body><h1>POST Test</h1><p>Data supplied was \""
        html=html+z
        html=html+"\"</P></body></html>"
        return HttpResponse(html)

When I run a test upload it fails:

$ wget --post-data 'data=Something'
http://localhost:8000/posttest?data=Command
Line
--2011-05-02 15:30:03--  http://localhost:8000/posttest?data=CommandLine
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:8000... connected.
HTTP request sent, awaiting response... 500 INTERNAL SERVER ERROR
2011-05-02 15:30:03 ERROR 500: INTERNAL SERVER ERROR.

If I don't supply any post data then it appears to work (301 followed by 200
codes, but still gives the expected html).

Any ideas what I'm doing wrong? (Get methods seem to work - but I'd prefer
not to use them because they're not technically correct for a DB update
function)

Thanks, Bob.

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