https://github.com/qu4tro/rest_framework_mixins
A collection of DRF mixins combinations
https://github.com/qu4tro/rest_framework_mixins
Last synced: about 2 months ago
JSON representation
A collection of DRF mixins combinations
- Host: GitHub
- URL: https://github.com/qu4tro/rest_framework_mixins
- Owner: Qu4tro
- License: mit
- Created: 2023-02-14T21:58:19.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-12-10T01:23:02.000Z (over 2 years ago)
- Last Synced: 2025-03-04T21:01:57.340Z (over 1 year ago)
- Language: Python
- Size: 34.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://www.django-rest-framework.org/api-guide/viewsets/#example_3)