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.7.tar.gz (2.3 kB view details)

Uploaded Source

Built Distribution

django_json_response-1.0.7-py2.7.egg (3.9 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for django-json-response-1.0.7.tar.gz
Algorithm Hash digest
SHA256 aab660b3d5a20eabbd2afce81a8b1446eb1ed76f190c5f5d419909aee8eaef06
MD5 dfc7f95b251a9b62194983015efb40b7
BLAKE2b-256 b8fab87b97a21f1976e6c2ca6de6137935f67be3b2c8c447b3f400c0e74e055f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_json_response-1.0.7-py2.7.egg
Algorithm Hash digest
SHA256 2d3eca56f63bba9f05be2d17c6ac89cb0c6c19f4cf6d8e678d16ebbf4e3beb7e
MD5 304e0abee9d56bc4dd7da1808d47aa7c
BLAKE2b-256 f8ef1f7dcb9d9fd9843ae237dc6ad51c5e49b7147f2c36aaa5e2a00b9e237f9d

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