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

Uploaded Source

Built Distribution

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

Uploaded Source

File details

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

File metadata

File hashes

Hashes for django-json-response-1.0.2.tar.gz
Algorithm Hash digest
SHA256 aa8f11131655ca1e148bf1a9e4f8e5b55b337059678ef29add63bd0d811b890e
MD5 d26ac2909383b2a7b916e668613edc5f
BLAKE2b-256 f1ce5f5f0da3692c7f2abacc57d4aea82dbe11bbae35efb7956a04d45fdd5a0f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_json_response-1.0.2-py2.7.egg
Algorithm Hash digest
SHA256 8db2db7d278423a216dea81b3e2bb88ce9eb72e75e99420910fd80f9bc908e5d
MD5 edbfe7de1a18678b6063c10b9df80287
BLAKE2b-256 7654d2762b6e590c096386fbead46bad0334ccd5d1188aad5115a7c06788f3a0

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