nested serializer for django-rest-framework
Project description
DRF Nested Serializer
Nested Serializer support for Django Rest Framework.
Example
class Goods(models.Model):
name = models.CharField(max_length=10)
category = models.CharField(max_length=20)
class GoodsImage(models.Model):
goods = models.ForeignKey(
Goods,
related_name='goods_images',
on_delete=models.CASCADE
)
image_key = models.CharField(max_length=10)
class GoodsSerializer(NestedModelSerializer):
class Meta:
model = Goods
fields = '__all__'
nested_fields = {'goods_images': 'goods'} # {related_name: field_name}
The above will allow to create the following queries
POST
{
"name": "string",
"category: "string",
"goods_images": [
{"image_key": "string"},
{"image_key": "string"},
{"image_key": "string"}
]
}
Project details
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 drf-nested-serializer-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0fcc25925abbabbfc5b08bac0de34b5883d45c84b00860348b816162e4c54d2 |
|
MD5 | f8c609ea5a73e78cbcbdccb0caae3a4d |
|
BLAKE2b-256 | de5645222fb5b2958bee0c4923659fae53d4d8061d8a12a722659081208bd25a |
Close
Hashes for drf_nested_serializer-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36b5987067c0a2a23b9b4016fac26cc562d920f98614c3fc2f3faf24feb49141 |
|
MD5 | 5af8ddde336a75aa5914eaf63c0da19b |
|
BLAKE2b-256 | a4aba95321188f328a6261b71f7f1ff3c0e19d4e892cfd68a73d9806a435b5d1 |