drf-flex-fields
Flexible, dynamic fields and nested resources for Django REST Framework serializers.
Decision gist · record as of 2026-08-14
Yes, if you are already committed to Django REST Framework and need flexible field control without building custom logic. The permissive MIT license and zero runtime dependencies make adoption low-risk. However, the dormant maintenance status (last commit October 2023, no release for over a year) is a real concern—verify compatibility with your Django and DRF versions before relying on it for new projects, and be prepared to fork or patch if breaking changes emerge upstream.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- High install friction with no runtime dependencies.
- The package is dormant—last commit was 2023-10-16 and no release in over a year—so expect limited maintenance and potential compatibility drift with newer Django or DRF versions.
License · maintenance · safety
MIT (permissive) — MIT license permits free use, modification, and distribution with minimal restrictions, making it safe for commercial and open-source projects.
last release 2023-03-11 (1252 days) · last repo commit 2023-10-16 · 768 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 215,044 downloads/mo, #9,406 on PyPI
Alternatives
Verify before relying
pip install drf-flex-fields
from rest_flex_fields import FlexFieldsModelSerializer
class CountrySerializer(FlexFieldsModelSerializer):
class Meta:
model = Country
fields = ('id', 'name', 'population', 'states')
expandable_fields = {'states': (StateSerializer, {'many': True})}
# GET /people/142/?expand=country.states- Compatibility with current Django and Django REST Framework versions (classifiers list Python up to 3.7 only)
- Whether the package works with modern async Django views or only synchronous serializers
- Performance impact of deep nested expansion on large datasets beyond the database query warnings in the description
What it is and what it does
drf-flex-fields extends Django REST Framework serializers to let API clients dynamically control which fields appear in responses and which nested relationships get fully expanded. Instead of returning fixed response shapes, you define expandable fields in your serializer's Meta class, then clients use query parameters like `?expand=country.states` or `?fields=id,name` to customize what they receive. The package supports dot notation for arbitrarily deep nesting, sparse field selection (include or exclude specific fields), and can be configured per-request or passed directly to serializer instantiation.
The package has no runtime dependencies and integrates as a mixin or base class for your existing DRF serializers. It includes a ViewSet subclass to prevent expensive expansions on list endpoints and utility functions to check expansion state in view logic. The core appeal is reducing over-fetching and under-fetching in REST APIs without duplicating serializer definitions.
Use it for
- Mobile apps that need lightweight responses with only essential fields to reduce bandwidth and latency
- Admin dashboards that request full nested details on demand without creating separate serializer variants
- GraphQL-like query control in REST APIs where clients specify exactly which relations to populate
- Preventing N+1 query problems by letting clients opt into expensive nested expansions rather than always including them
- Reusing a single serializer across multiple endpoints with different response shape requirements
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you are already committed to Django REST Framework and need flexible field control without building custom logic.
The permissive MIT license and zero runtime dependencies make adoption low-risk. However, the dormant maintenance status (last commit October 2023, no release for over a year) is a real concern—verify compatibility with your Django and DRF versions before relying on it for new projects, and be prepared to fork or patch if breaking changes emerge upstream.
Install
drf-flex-fields on PyPI
Before you install
High install friction with no runtime dependencies. The package is dormant—last commit was 2023-10-16 and no release in over a year—so expect limited maintenance and potential compatibility drift with newer Django or DRF versions.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions, making it safe for commercial and open-source projects.
Quickstart
pip install drf-flex-fields
from rest_flex_fields import FlexFieldsModelSerializer
class CountrySerializer(FlexFieldsModelSerializer):
class Meta:
model = Country
fields = ('id', 'name', 'population', 'states')
expandable_fields = {'states': (StateSerializer, {'many': True})}
# GET /people/142/?expand=country.states
Verify before relying
- Compatibility with current Django and Django REST Framework versions (classifiers list Python up to 3.7 only)
- Whether the package works with modern async Django views or only synchronous serializers
- Performance impact of deep nested expansion on large datasets beyond the database query warnings in the description
Package facts
| License | MIT permissive |
| Python support | Not specified |
| Install friction | High. Source build required |
| Runtime dependencies | None |
| Maintenance | Dormant 1,252 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 215,044 / month, #9,406 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.2Programming Language :: Python :: 3.3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7 |
Evidence: drf-flex-fields-1.0.2.tar.gz
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “django rest framework dynamic fields”
- drf-flex-fieldsAdds dynamic field expansion and sparse field selection to Django…
- drf-dynamic-fieldsProvides a Django REST Framework mixin that lets you dynamically…
- drf-extra-fieldsProvides specialized serializer fields for Django REST Framework,…
Give your agent the search over MCP, or paste the wish link into any chat.
More Dynamic Content packages
MarkupSafe provides a text object that escapes special characters so untrusted strings can be safely embedded in HTML and XML without injection attacks.
Jinja2 is a templating engine that renders dynamic content by combining templates with Python-like syntax and data, supporting template inheritance, macros, autoescaping, and sandboxed execution.
Soupsieve is a CSS selector library designed to work with Beautiful Soup 4 to select, match, and filter HTML and XML elements using modern CSS selectors from CSS level 1 through CSS level 4 specifications.
Install it if you use Beautiful Soup for HTML or XML parsing and want modern CSS selector support.
Werkzeug is a WSGI utility library providing request/response objects, URL routing, an interactive debugger, HTTP utilities, and a development server for building web applications.
Flask is a lightweight WSGI web application framework for building web applications in Python, from simple single-page sites to complex multi-route applications.
Mako compiles Python-embedded templates into Python modules for fast rendering, supporting layout inheritance, custom functions, and direct Python expressions within template syntax.
See also drf-dynamic-fields · drf-writable-nested · drf-nested-routers · djangorestframework-dataclasses · rest-framework-generic-relations · djangorestframework-role-filters · drf-rw-serializers · drf-extra-fields · drf-jsonschema-serializer · drf-access-policy