DIY Django's JsonResponse and JsonpResponse
Project description
django-json-response
JsonResponse 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] } }) or 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.6.tar.gz
.
File metadata
- Download URL: django-json-response-1.0.6.tar.gz
- Upload date:
- Size: 2.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | daa224eed2cfe8a468a2f3ae53eb748a119289d005d1dc085af7bf2867bcabba |
|
MD5 | e7448783ce23c11406f81e532c2d0d92 |
|
BLAKE2b-256 | 3138992bb7112556c9d21bb5695d42737456acdf409251040427fe5f7a5de185 |
Provenance
File details
Details for the file django_json_response-1.0.6-py2.7.egg
.
File metadata
- Download URL: django_json_response-1.0.6-py2.7.egg
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 807e57c22be58516d45e8f1cec257783aa87fb4cd08e5599d201f78b325d0ea3 |
|
MD5 | 604def2fa7f2c71a79762aafc19c1e5e |
|
BLAKE2b-256 | e3d389fff41a8e4d770b33e95de8afe92b374e3f88386e03d9521a76a83a23f5 |