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]
}
})
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-json-response-1.0.3.tar.gz
.
File metadata
- Download URL: django-json-response-1.0.3.tar.gz
- Upload date:
- Size: 2.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8b5d09973a0634695f8e89c8365021cef43a854197e39cb5016399ac073bb1d |
|
MD5 | f31b889b0ae3016eaddd3a67188b6acf |
|
BLAKE2b-256 | befcf0e6ad3203480c42e722c337dc8fa2a84cdf9a0c0925ff5010890febe2ef |
Provenance
File details
Details for the file django_json_response-1.0.3-py2.7.egg
.
File metadata
- Download URL: django_json_response-1.0.3-py2.7.egg
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 413f4ded6fa7c77660b544fd5eb628ab314cda9384f97e1490a1a27f63a1142f |
|
MD5 | a08e0c1beca22004a79963a0ca06775e |
|
BLAKE2b-256 | a3e7593fcca3a4abe9b1a47a030a99e3212103198d5934d7f7a3bd83277cd29c |