Skip to content

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

2 watching

Forks

Repository files navigation

Django Rest Framework Aggregation

A Django REST Framework mixin that adds an aggregation endpoint (count, sum, average, minimum, maximum) with grouping, filtering and ordering to your ViewSets.

uv add django-rest-aggregation
from django_rest_aggregation import AggregationMixin
from rest_framework.viewsets import GenericViewSet


class BookViewSet(AggregationMixin, GenericViewSet):
    queryset = Book.objects.all()
    serializer_class = BookSerializer
GET /book/aggregation/?aggregation=average&aggregation_field=rating&group_by=author

Based on kit-oz/drf-aggregation.

Documentation

The documentation is split into small linked notes in Readme/.

Using the package

  • Installation: install, dependencies, INSTALLED_APPS
  • Quickstart: add the mixin, register the route, example requests and responses
  • Query parameters: all URL parameters at a glance
  • Aggregations: aggregation types, aliases, allowed field types
  • Grouping: group_by, relation paths, multiple fields
  • Filtering: filtering before and after aggregation, value FilterSets
  • Ordering: ordering, allowed fields, pitfalls
  • Field access: which fields group_by / aggregation_field may use (aggregation_fields, aggregation_models), limits
  • Customization: value name, serializer, pagination, overridable hooks
  • View attributes: reference of all class attributes

Working on the package

License

MIT, see LICENSE.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages