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.4.tar.gz
.
File metadata
- Download URL: django-json-response-1.0.4.tar.gz
- Upload date:
- Size: 2.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27fc8dab35b5e0fd1cea38538788dd068b05a4e53bf9503f79d65ff49b2b63e3 |
|
MD5 | 9d639c7dabafab37171e6c013eb3ebe0 |
|
BLAKE2b-256 | 124d34bb0d575c753d07438373ceb0295a6b311728da86776d4ceae901632b43 |
File details
Details for the file django_json_response-1.0.4-py2.7.egg
.
File metadata
- Download URL: django_json_response-1.0.4-py2.7.egg
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4474a3290b3cc0d1bb86afd2d7c7362a38a2f125440ddaedec7d9960051abd3b |
|
MD5 | e833186d3290b4eafab546d55232147f |
|
BLAKE2b-256 | 5554ef203b27aaba5d353b70b5acb139ef7c18f2f6c28f8dae779bcf41ce690b |