2👍
✅
What’s your urlconf look like? If it looks like '^web_app/$'
and APPEND_SLASH=True
in settings, which is default, you need to use "http://127.0.0.1:8000/web_app/"
(note the suffix slash). Or else Django would try to redirect /web_app
to /web_app/
if there is no matching, then complains about redirecting a POST
request.
Also, its meaningless to set 'Content-Type':'application/json'
for HTTP request, you could set this and break the requirement of urllib2 by passing it a JSON-dumped string; but then you should parse request.body
by yourself instead of using request.POST
. application/json
is normally for specifying the Content-Type
of response.
👤okm
Source:stackexchange.com