I am trying to do REST Api in Django by outputting Json. I am having problems if I make a POST request using curl in a terminal. The error I get is this
You call this URL via POST, but the URL does not end with a slash and you have APPEND_SLASH set. Django cannot redirect slash URLs while saving POST data. Change the form to point to 127.0.0.1:8000/add/( pay attention to the trailing slash) or set APPEND_SLASH = False in the Django settings.
My url.py
from django.conf.urls.defaults import patterns, include, url import search
and my views
# Create your views here. from django.http import HttpResponse from django.template import Context,loader import memcache import json def query(request): data=['a','b'] mc=memcache.Client(['127.0.0.1:11221'],debug=0) mc.set("d",data); val=mc.get("d") return HttpResponse("MEMCACHE: %s<br/>ORIGINAL: %s" % (json.dumps(val),json.dumps(data)) ) def add(request):
I know that it does not give Json, but I have the problem mentioned above when I make a POST request in terminal
curl http://127.0.0.1:8000/add/ -db=2 >> output.html
I am new to django.
python django restful-architecture
Zabi
source share