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
For Designing API's
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
select_related = ['key1' , 'key2']
prefetch_related = ['key1' , 'key2']
permission_classes = [IsAuthenticated]
enable_cache = True
cache_duration = 60
query_params = {
"name": "name",
"related_field__id": "related_id",
"related_field__name": "related_name",
}
pagination = True
- with query params
e.g., localhost:8000/view/?name="anand"&related_id=1&related_name="anandraj"
- with pagination
e.g., localhost:8000/view/?page_size=10&page_number=1"
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
select_related = ['key1' , 'key2']
prefetch_related = ['key1' , 'key2']
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)
For Designing serializers
For creating new serializer instance
DjeasyModelSerializer.options(
model_name=UserModel,
queryset=UserModel.objects.all(),
fields="__all__",
many=True,
display_fields={"id","name","email","password","profile"},
related_fields={
"profile": {
"many": False,
"read_only": True,
"slug_field": "display_name",
},
},
access_fields={"password": "read_only"},
rename_fields = {"name" : "username"}
).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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file djeasyview-1.0.15.tar.gz.
File metadata
- Download URL: djeasyview-1.0.15.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
664b40135488474fd523ba4f7a75f8f464f5c3d571b958631a11022cbb1655d2
|
|
| MD5 |
500715cfdb79164762f97fec5962b6de
|
|
| BLAKE2b-256 |
74d6fafa5a8bc41a133f95eca0958837705b8b7a906b11b9afddb937ec9956cc
|
File details
Details for the file djeasyview-1.0.15-py3-none-any.whl.
File metadata
- Download URL: djeasyview-1.0.15-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d427dd1947de65b58c320490194546d9a7747cab70d45a3ac43cde4ed6e5f5dc
|
|
| MD5 |
07359c4a4d3e2c36872416b548cbfb3b
|
|
| BLAKE2b-256 |
4e5f3218edcf997bf09614a87aef569a3a27ffeaa7ad3228ad6be9cac44da3f2
|