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

Uploaded Source

Built Distribution

django_json_response-1.0.6-py2.7.egg (3.8 kB view details)

Uploaded Source

File details

Details for the file django-json-response-1.0.6.tar.gz.

File metadata

File hashes

Hashes for django-json-response-1.0.6.tar.gz
Algorithm Hash digest
SHA256 daa224eed2cfe8a468a2f3ae53eb748a119289d005d1dc085af7bf2867bcabba
MD5 e7448783ce23c11406f81e532c2d0d92
BLAKE2b-256 3138992bb7112556c9d21bb5695d42737456acdf409251040427fe5f7a5de185

See more details on using hashes here.

File details

Details for the file django_json_response-1.0.6-py2.7.egg.

File metadata

File hashes

Hashes for django_json_response-1.0.6-py2.7.egg
Algorithm Hash digest
SHA256 807e57c22be58516d45e8f1cec257783aa87fb4cd08e5599d201f78b325d0ea3
MD5 604def2fa7f2c71a79762aafc19c1e5e
BLAKE2b-256 e3d389fff41a8e4d770b33e95de8afe92b374e3f88386e03d9521a76a83a23f5

See more details on using hashes here.

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