--- id: drf-writable-nested version: "0.7.2" license: BSD license_treatment: permissive maintenance: aging --- # drf-writable-nested — Writable nested helpers for django-rest-framework's serializers License: permissive · Maintenance: aging · Downloads: 735.7K/mo ## What it is and what it does DRF Writable Nested is a Django REST Framework extension that lets you serialize and deserialize nested model relationships—OneToOne, ForeignKey, ManyToMany, and GenericRelation—in a single API request. Instead of making separate calls to create or update related objects, you pass a nested data structure to the serializer, and it handles all the database operations atomically. The package provides WritableNestedModelSerializer as the main class, plus NestedCreateMixin and NestedUpdateMixin for more granular control. It also includes UniqueFieldsMixin to handle validation of unique fields on nested updates. The serializer automatically creates or updates all related instances and returns a complete object graph, making it useful for APIs that need to accept complex, hierarchical input in a single request. Use it for: - Accept a user profile with nested sites, access keys, and avatars in one POST request instead of multiple API calls. - Update a parent object and its related children (e.g., a voucher and its line items) via a single PATCH or PUT. - Build admin-style APIs where clients submit entire object trees with related data and expect atomic creation or update. - Simplify client code by eliminating the need to orchestrate multiple serializer calls for interdependent model hierarchies. - Handle reverse relationships (e.g., a user's profile, or a profile's avatars) without flattening or restructuring the data. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Extends Django REST Framework serializers to handle creation and updates of nested model relationships (OneToOne, ForeignKey, ManyToMany, GenericRelation) in a single request. Yes, if you are building Django REST Framework APIs that accept nested model data. The package is stable (BSD licensed, no known vulnerabilities, 1139 GitHub stars), has low install friction, and solves a common pain point in DRF. The aging maintenance status (522 days since last release) is a minor concern for long-term support, but the repository remains active and the package supports current Django and Python versions. Install it when you need to handle nested creates/updates; skip it if your API only works with flat, single-model payloads. ## Install pip install drf-writable-nested uv add drf-writable-nested poetry add drf-writable-nested ## Installing drf-writable-nested Before you install: Low install friction with no runtime dependencies. Maintenance status is aging—last release was 522 days ago, though the repository remains active with recent commits and 1139 stars. Suitable for projects on Django 4.2–5.2 and Python 3.9–3.13. License in practice: BSD license is permissive, allowing commercial and private use with minimal restrictions. Include a copy of the license in distributions. Quickstart: pip install drf-writable-nested from drf_writable_nested.serializers import WritableNestedModelSerializer class ProfileSerializer(WritableNestedModelSerializer): sites = SiteSerializer(many=True) access_key = AccessKeySerializer(allow_null=True) class Meta: model = Profile fields = ('pk', 'sites', 'access_key') data = {'sites': [{'url': 'http://example.com'}], 'access_key': {'key': 'abc'}} serializer = ProfileSerializer(data=data) serializer.is_valid(raise_exception=True) instance = serializer.save() Requires Django 4.2+ and djangorestframework 3.14+; Python 3.9 or later. Verify before relying: - Whether the aging maintenance status (522 days since last release) affects stability for new Django/Python versions beyond 5.2 and 3.13. - Performance characteristics when handling deeply nested or large-scale related data structures. - Compatibility with third-party DRF extensions or custom serializer mixins beyond those documented. ## Package facts - License: BSD (permissive) - Python support: supports_current - Install friction: low - Maintenance: aging - Downloads: 735.7K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags django rest framework nested serializer, drf writable nested relations, create update nested models django, django rest framework foreign key serializer, nested model serialization django, drf many-to-many nested, django rest framework one-to-one nested, django-rest-framework, serialization, nested-data [View on SkillFed](https://skillfed.io/packages/drf-writable-nested) · [View on PyPI](https://pypi.org/project/drf-writable-nested/)