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]
}
})
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
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
Close
Hashes for django-json-response-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87f6a413e58f7631845b6211da281caa64d8dc31ab06f65fc1716280b52ece68 |
|
MD5 | be932a0943a09d1d118268b392ae0f21 |
|
BLAKE2b-256 | 17e144e37848786ed21b573afdff79778b44d758b8f0540b6b76953343e3db0e |
Close
Hashes for django_json_response-1.0.1-py2.7.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95d405c89fc80a2148e1f4df66a3247a9eb889aa1417b23e3ecd5c2cd06e763a |
|
MD5 | 5f0105c7ecf6f71f48cea410b609f5b5 |
|
BLAKE2b-256 | b9523c0a6db9053edf18ee999f910a3e3840a53170346742bd83fbdf0c11b38d |