Simple JSONP support for django
Install using pip
...
$ pip install django-jsonp
from djsonp import jsonp, JSONPResponse, get_callback
# decorate something that returns a dict-like object
@jsonp
def my_view(request):
return {'foo': 'bar'}
# it can work with an HttpResponse instances
@jsonp
def another_view(request):
return HttpResponse("{'foo': 'bar'}")
# or just return a JSONPResponse
def jsonp_view(request):
return JSONPResponse(data={'foo': 'bar', }, callback=get_callback(request))