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

* JsonResponse::

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


* JsonpResponse::

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

Uploaded Source

Built Distribution

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

Uploaded Source

File details

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

File metadata

File hashes

Hashes for django-json-response-1.0.3.tar.gz
Algorithm Hash digest
SHA256 c8b5d09973a0634695f8e89c8365021cef43a854197e39cb5016399ac073bb1d
MD5 f31b889b0ae3016eaddd3a67188b6acf
BLAKE2b-256 befcf0e6ad3203480c42e722c337dc8fa2a84cdf9a0c0925ff5010890febe2ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_json_response-1.0.3-py2.7.egg
Algorithm Hash digest
SHA256 413f4ded6fa7c77660b544fd5eb628ab314cda9384f97e1490a1a27f63a1142f
MD5 a08e0c1beca22004a79963a0ca06775e
BLAKE2b-256 a3e7593fcca3a4abe9b1a47a030a99e3212103198d5934d7f7a3bd83277cd29c

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