Observed since 20 Oct, 19:50 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Flexible, dynamic fields and nested models for ADRF (Async Django REST Framework) serializers
Flexible, dynamic fields and nested models for ADRF (Async Django REST Framework) serializers.
ADRF Flex Fields extends the Async Django REST Framework (ADRF) with powerful field expansion and dynamic serialization capabilities. This package allows you to create more flexible APIs by enabling clients to specify which fields they want to include in responses, reducing over-fetching and improving performance.
pip install adrf_flex_fields
from adrf_flex_fields import FlexFieldsModelSerializer
from adrf import serializers
from myapp.models import User, Profile
class UserSerializer(FlexFieldsModelSerializer):
class Meta:
model = User
fields = ['id', 'username', 'email', 'profile']
expandable_fields = {
'profile': ProfileSerializer
}
# Usage in views
class UserViewSet(AsyncModelViewSet):
serializer_class = UserSerializer
queryset = User.objects.all()
Clients can control which fields are returned:
# Get only id and username
GET /api/users/?fields=id,username
# Exclude email field
GET /api/users/?omit=email
# Expand nested profile
GET /api/users/?expand=profile
class UserSerializer(FlexFieldsModelSerializer):
class Meta:
model = User
fields = ['id', 'username', 'email', 'profile', 'posts']
expandable_fields = {
'profile': ProfileSerializer,
'posts': (PostSerializer, {'many': True})
}
# Custom field filtering
def get_field_names(self, declared_fields, info):
field_names = super().get_field_names(declared_fields, info)
# Custom logic here
return field_names
git clone https://github.com/mushota_243/adrf-flex-fields.git
cd adrf-flex-fields
pip install -e ".[dev]"
pytest
pytest --cov=adrf_flex_fields --cov-report=html
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions, please open an issue on GitHub.
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.1.0 | 21 Jan 2026 | 8 |
This describes our collected data; it is not a security assessment.
Shared repository data · GitHub
Observed since 20 Oct, 19:50 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:f3a8879428639205dab3a836d6c842bf5bbd52965df3b5cc443f60dbbc7df96f