Django JSON Serializer
This is a django serializer that outputs sensible json to be sent to the frontend, rather than intended as a serializer to a file. Here’s an example:
>>> print s.serialize(User.objects.all(), relations=['groups'], excludes=['user_permissions'], indent=4)
[
{
"username": "dusty",
"first_name": "",
"last_name": "",
"is_active": true,
"is_superuser": true,
"is_staff": true,
"last_login": "2010-11-26 13:27:07",
"groups": [
{
"pk": 1,
"model": "auth.group",
"name": "hello",
"permissions": []
}
],
"pk": 1,
"model": "auth.user",
"password": "sha1$8f816$b4c8139100c314b46f1ca931858e4d6d5c61917f",
"email": "dusty@linux.ca",
"date_joined": "2010-11-22 17:55:40"
}
]
The default serializer (djason.json) spits out a list of objects as a string. You can optionally have it return that list wrapped in an HttpResponse object by passing the httpresponse=True option into serialize.
There is a second serializer that takes two optional parameters, attributes (a dict) and list_name (a string). This serializer returns a dictionary with any key value attributes in the attributes dictionary, and one extra attribute named list_name, which contains the list of objects as returned by the json serializer. For example:
>>> print s.serialize(User.objects.all(), relations=['groups'], excludes=['user_permissions'], indent=4, attributes={'somekey': 'somevalue'}, list_name="users")
{
"somekey": "somevalue",
"users": [
{
"username": "dusty",
"first_name": "",
"last_name": "",
"is_active": true,
"is_superuser": true,
"is_staff": true,
"last_login": "2010-11-26 13:27:07",
"groups": [
{
"pk": 1,
"model": "auth.group",
"name": "hello",
"permissions": []
}
],
"pk": 1,
"model": "auth.user",
"password": "sha1$8f816$b4c8139100c314b46f1ca931858e4d6d5c61917f",
"email": "dusty@linux.ca",
"date_joined": "2010-11-22 17:55:40"
}
]
}
This project was originally forked from: https://code.google.com/p/wadofstuff/wiki/DjangoFullSerializers
The original code produced a json format that was good for ./manage.py dump and load, but wasn’t as suitable for sending data to a web client for processing via ajax.
What’s new
Version 0.2 - Added a serializer that allows including the serialized object inside an object with extra attributes - Added an ‘httpresponse’ option that will automatically wrap the serialized stream in an HttpResponse object Version 0.1
First public released
forked from https://code.google.com/p/wadofstuff/wiki/DjangoFullSerializers
patched with https://code.google.com/p/wadofstuff/issues/detail?id=4
Modified to output more sensible json for client consumption
Turned it into a django app
Added a template tag for rendering raw django
Metadata
Release files for djason 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| djason-0.2.1.tar.gz | 6.9 kB | Without provenance | Details for djason-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| djason-0.2.1.linux-i686.tar.gz | Details for djason-0.2.1.linux-i686.tar.gz |
Total release size: 22.3 kB
Release files / djason-0.2.1.tar.gz
| Download URL | djason-0.2.1.tar.gz |
|---|---|
| Size | 6.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ea52ab35e7a9f6e392d6b01ca0cd911abf8baba971c43a6b58fcede63b63497a
|
|
BLAKE2b-256 checksum How to use checksums |
c0009ce9c13eb883236892c182e878f13ce43b996709fe4e46a67ee49d72cd97
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / djason-0.2.1.linux-i686.tar.gz
| Download URL | djason-0.2.1.linux-i686.tar.gz |
|---|---|
| Size | 15.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cf7941add51129b343127f8294849e788b2de091738f89907e64624bcb94f4d9
|
|
BLAKE2b-256 checksum How to use checksums |
41db9f948266878315e0c7e88996f2f025ece4054c3d4423b1dc91c43c9c12a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for djason 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.