Skip to main content

DIY Django's JsonResponse and JsonpResponse

Project description

django-json-response

Installation

pip install django-json-response

Usage

from json_response import JsonResponse

def excelview(request):
    objs = SomeModel.objects.all()

    return JsonResponse({
        'status': 200,
        'message': u'成功'
        'data': {
            'data1': 'xxx',
            'data2': 'ooo',
            'objs': [obj.data for obj in objs]
        }
    })


or


from json_response import JsonpResponse

def excelview(request):
    callback = request.GET.get('callback', '')

    objs = SomeModel.objects.all()

    return JsonpResponse(callback, {
        'status': 200,
        'message': u'成功'
        'data': {
            'data1': 'xxx',
            'data2': 'ooo',
            'objs': [obj.data for obj in objs]
        }
    })

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-json-response-1.0.6.tar.gz (2.2 kB view hashes)

Uploaded Source

Built Distribution

django_json_response-1.0.6-py2.7.egg (3.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