--- id: drf-dynamic-fields version: "0.4.0" license: MIT license_treatment: permissive maintenance: aging --- # drf-dynamic-fields — Dynamically return subset of Django REST Framework serializer fields License: permissive · Maintenance: aging · Downloads: 147.9K/mo ## What it is and what it does drf-dynamic-fields is a mixin for Django REST Framework serializers that lets API clients control which fields appear in responses via query parameters. Instead of always returning all fields, clients can pass `?fields=id,name` to get only those fields, or `?omit=email` to exclude specific ones. The mixin intercepts the serialization process and dynamically removes unwanted fields before rendering the response. The package is deliberately minimal—it handles flat field filtering only and does not plan to add support for nested fields. It integrates by inheriting from DynamicFieldsMixin alongside your serializer class, and requires the request object to be available in the serializer's context. The implementation is stable and has been in production use since first release in 2016, though development has slowed (last release in April 2022). Use it for: - Reduce API response payload size by letting mobile clients request only essential fields over bandwidth-constrained connections. - Build flexible APIs where frontend teams can request exactly the fields they need without creating multiple endpoints. - Optimize database query results by excluding heavy computed or related fields that aren't needed for a particular request. - Support legacy API clients that expect different field subsets without duplicating serializer logic across endpoints. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides a Django REST Framework mixin that lets you dynamically select which serializer fields to include or exclude per request using query parameters. Yes, if you are using Django REST Framework and need simple per-request field filtering. The package has no dependencies, low install friction, and a permissive MIT license. However, the aging maintenance status (last release April 2022) means you should verify compatibility with your Django 2.2 LTS, 3.2 LTS, or 4.0 and DRF 3.8 or 3.9 versions before adopting it. ## Install pip install drf-dynamic-fields uv add drf-dynamic-fields poetry add drf-dynamic-fields ## Installing drf-dynamic-fields Before you install: Low install friction with no runtime dependencies. Package is aging (last release April 2022, 1592 days ago) but marked Production/Stable and the repository remains active and unarchived. License in practice: MIT license is permissive and imposes no restrictions on use, modification, or redistribution in proprietary or open-source projects. Quickstart: pip install drf-dynamic-fields from drf_dynamic_fields import DynamicFieldsMixin class MySerializer(DynamicFieldsMixin, serializers.ModelSerializer): class Meta: model = MyModel fields = ('id', 'name', 'email') # Then use: GET /api/endpoint/?fields=id,name Requires Django 2.2 LTS, 3.2 LTS, or 4.0; requires Django REST Framework 3.8 or 3.9; request object must be passed to serializer context for the mixin to function. Verify before relying: - Whether the package works with Django versions beyond 4.0 or DRF versions beyond 3.9. - Performance characteristics when filtering large numbers of fields or handling deeply nested serializers. - Compatibility with Python versions beyond 3.7+. ## Package facts - License: MIT (permissive) - Python support: unspecified - Install friction: low - Maintenance: aging - Downloads: 147.9K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags django rest framework dynamic fields, drf serializer field filtering, rest api selective field response, django api query parameter fields, drf mixin field selection, django-rest-framework, api-optimization, serialization [View on SkillFed](https://skillfed.io/packages/drf-dynamic-fields) · [View on PyPI](https://pypi.org/project/drf-dynamic-fields/)