Reputation: 3236
I'm trying to send a POST request from iPhone to Django, but for some reason I can't. The request is sent, but the server doesn't receive it properly.
/messages/a/s=person1&r=person2&c=hello/
.request.POST['s']
should work?Thanks.
Upvotes: 0
Views: 232
Reputation: 9474
POST parameters are not part of the URL, so your regex should simply detail the main part of the url you want to receive it on. To take your example, change it to /messages/a/
. Then, in your "messages" app, have a view/function called a
: that one will be reached on receiving any POST (or GET, which you're currently (almost) depicting in your url) to that location.
The arguments can then indeed be retrieved using request.POST['keyname']
. To make things more convenient, supply a default value when getting the data so you need less error checking: request.POST.get('keyname', None)
. This will get the value of keyname
when available, or None
otherwise.
The posting itself... depends on more code then you're currently showing. Can't say anything about that with your current question.
Upvotes: 4
Reputation: 40203
That URL you've pasted in will pass the data through the request.GET
dictionary. If you want to change your iPhone app to POST data, you'll have to share your code.
Upvotes: 3