No project description provided
Project description
Dj Easy view CRUD mixins
Makes your CRUD's even more smaller and customizable with dj easy views .
Installation
pip install djeasyview
Usage
GET and POST api's
This mixin provides generic implementations for listing and creating resources.
Example:
from djeasyview import DjeasyListCreateView
from your_app.models import YourModel
from your_app.serializers import YourModelSerializer
from rest_framework.permissions import IsAuthenticated
class YourView(DjeasyListCreateView):
model = YourModel
list_serializer_class = YourModelSerializer
create_serializer_class = YourModelSerializer
serializer_class = YourModelSerializer
queryset = YourModel
permission_classes = [IsAuthenticated]
enable_cache = True
cache_duration = 60
GET , PUT , PATCH , DELETE api's
This mixin provides generic implementations for Retrive , updating and deleting resources.
from djeasyview import DjeasyRetrieveUpdateApiView
from your_app.models import YourModel
from your_app.serializers import YourModelSerializer
from rest_framework.permissions import IsAuthenticated
class YourView(DjeasyRetrieveUpdateApiView):
model = YourModel
list_serializer_class = YourModelSerializer
create_serializer_class = YourModelSerializer
serializer_class = YourModelSerializer
queryset = YourModel
permission_classes = [IsAuthenticated]
enable_cache = True
cache_duration = 60
Customization:
-
customize your get_queryset
def get_queryset(self): super().get_queryset() return YourModel.objects.filter(**filter_conditions)
-
customize your responses
from rest_framework.response import Response def get_response(self, serializer_klass, queryset): super().get_response(serializer_klass, self.get_queryset()) return Response(serializer_klass(queryset).data)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
djeasyview-1.0.7.tar.gz
(3.9 kB
view hashes)
Built Distribution
Close
Hashes for djeasyview-1.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00b4ba0fd35d59bcab42624cf3d1a3fe1c3197c1b47e4fb577eb49aacfa8aadb |
|
MD5 | e4e542fd443aa8e99cf37832d9aa1db9 |
|
BLAKE2b-256 | 42bd64ffad09cb173e41c16ca0f22adda47642b51880b3ed9ff1831f85d49cb3 |