Skip to main content

A collection of DRF mixins combinations

Project description

rest-framework-mixins

Installation

pip install rest_framework_mixins

Usage

This package provides all combinations of the mixins provided by rest_framework.
All combinations follow the same format: `{initials}Mixin.

The initials correspond to the following methods, in this specific order:

  • L: list()
  • R: retrieve()
  • C: create()
  • U: update()
  • P: partial_update()
  • D: delete()

So for example, to import a mixin that gives us list, retrieve and create, we can do the following:

from rest_framework_mixins import LRCMixin

class CreateListRetrieveViewSet(LRCMixin, viewsets.GenericViewSet):
    """
    A viewset that provides `retrieve`, `create`, and `list` actions.

    To use it, override the class and set the `.queryset` and
    `.serializer_class` attributes.
    """
    pass

Adapted from DRF's documentation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rest_framework_mixins-1.0.0.tar.gz (4.2 kB view hashes)

Uploaded Source

Built Distribution

rest_framework_mixins-1.0.0-py3-none-any.whl (5.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page