Skip to main content

Simple JSONP support for django

Project description

Simple JSONP support for django

Coverage Status Build Status PyPI version Scrutinizer Code Quality Code Health

Installation

Install using pip

$ pip install django-jsonp

Usage

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

# it also works for CBVs
from django.views.generic import View

@jsonp
class DictResponse(View):
    def get(self, request):
        return HttpResponse("{'foo': 'bar'}")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_jsonp-0.3.0.tar.gz (2.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page