Skip to main content

DIY Django's JsonResponse and JsonpResponse

Project description

======================
django-json-response
======================

django-json-response
======================

class JsonResponse(data, encoder=DjangoJSONEncoder, safe=True, **kwargs) is New in Django 1.7
Ref: https://docs.djangoproject.com/en/1.8/ref/request-response/#jsonresponse-objects

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

::

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

Uploaded Source

Built Distribution

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

Uploaded Source

File details

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

File metadata

File hashes

Hashes for django-json-response-1.0.1.tar.gz
Algorithm Hash digest
SHA256 87f6a413e58f7631845b6211da281caa64d8dc31ab06f65fc1716280b52ece68
MD5 be932a0943a09d1d118268b392ae0f21
BLAKE2b-256 17e144e37848786ed21b573afdff79778b44d758b8f0540b6b76953343e3db0e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_json_response-1.0.1-py2.7.egg
Algorithm Hash digest
SHA256 95d405c89fc80a2148e1f4df66a3247a9eb889aa1417b23e3ecd5c2cd06e763a
MD5 5f0105c7ecf6f71f48cea410b609f5b5
BLAKE2b-256 b9523c0a6db9053edf18ee999f910a3e3840a53170346742bd83fbdf0c11b38d

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