Adds support for writable nested serializers to the Django REST framework.
Project description
DRF Nested Serializer
Adds support for writable nested serializers to the Django REST framework.
Find out more with the Getting Started guide.
Features
- All relationship types
- Including through model
- Drop-in replacement
- Create and update support
- Flexible field in- and exclusion
Example
from rest_framework.serializers import ModelSerializer
from drf_nested_serializer.serializer import NestedModelSerializer
from .models import MyChildModel, MyParentModel
class MyChildSerializer(ModelSerializer):
class Meta:
model = MyChildModel
fields = ("id", "")
class MyParentSerializer(NestedModelSerializer):
nested = MyChildSerializer()
class Meta:
model = MyParentModel
fields = ("id", "nested")
data = {
"child": {
"name": "John Doe"
}
}
serializer = MyParentSerializer(data=data)
if serializer.is_valid():
instance = serializer.save()
print(MyParentSerializer(instance=instance).data)
{
"id": 1,
"child": {
"id": 1,
"name": "John Doe"
}
}
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file drf_nested_model_serializer-0.0.2.tar.gz.
File metadata
- Download URL: drf_nested_model_serializer-0.0.2.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab521b737032941c3a01df8a711920cc3d13be8d585ba77cd86738fb77a00149
|
|
| MD5 |
0591f52374010932b10e6ae05d802239
|
|
| BLAKE2b-256 |
f7757b722546049d6355a46dee949978fefbef4f56f2708c2116f88f1ea681cd
|
File details
Details for the file drf_nested_model_serializer-0.0.2-py3-none-any.whl.
File metadata
- Download URL: drf_nested_model_serializer-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a3ed7030c240acd4ec41d281a2cdc7ed94c6e9074c56a82ed83802cad46bc79
|
|
| MD5 |
9be1a4617d348f17af0a357a2499fdcd
|
|
| BLAKE2b-256 |
5547216b1891ac8a2f33c1f2d0017f8268f645d9927a3d0d0b8cd52bdd3f49b0
|