⚠️ Warning NonPaginatedXLSXRenderer does not work with newer versions of drf-renderer-xlsx. Please set your version of drf-renderer-xlsx to 0.3.8.
django-rest-framework-more
More Cool Django Rest Framework Stuff
install
pip3 install djangorestframework-more or pipenv install djangorestframework-more
features
NonPaginatedCSVRenderer and NonPaginatedXLSXRenderer
In case you want a CSV or XLSX (Excel) renderer that doesn't respect pagination:
# in settings.py
REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': [
'rest_framework.renderers.JSONRenderer',
'rest_framework.renderers.BrowsableAPIRenderer',
'rest_framework_more.renderers.NonPaginatedCSVRenderer',
'rest_framework_more.renderers.NonPaginatedXLSXRenderer'
]
}
If you'd like to learn more about using renderers in Django Rest Framework, see https://www.django-rest-framework.org/api-guide/renderers/#setting-the-renderers
Creater Model Serializer Class
# in serializers.py
from app.models import Car
from rest_framework_more.serializers import create_model_serializer_class
CarSerializer = create_model_serializer_class(model=Car)
Create Model Filter Form
# forms.py
from app.models import Car
from rest_framework_more.filters import create_model_filter_form
CarFilterForm = create_model_filter_form(model=Car)
Create Model Filter Set Class
# forms.py
from app.models import Car
from rest_framework_more.filters import create_model_filterset_class
CarFilterSet = create_model_filterset_class(model=Car)
Create Model ViewSet Class
# views.py
from app.models import Car
from rest_framework_more.viewsets import create_model_viewset_class
CarViewSet = create_model_viewset_class(model=Car)
FileNameMixin
The FileNameMixin automatically generates a more descriptive filename for CSV and Excel exports than the default "download". It first tries to convert the url path into a filename. If that doesn't succeed it tries to pull the filename from the queryset's model.
# views.py
from rest_framework_more.mixins import FileNameMixin
class CarViewSet(FileNameMixin, ReadOnlyModelViewSet):
...
# if the CarViewSet is called from the url /api/cars it will generate a download filename of api_cars.csv
contact
If you have any issues, feel free to post an issue at https://github.com/DanielJDufour/django-rest-framework-more/issues or email the package author at daniel.j.dufour@gmail.com
Metadata
Release files for djangorestframework-more 1.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| djangorestframework-more-1.5.0.tar.gz | 10.8 kB | Without provenance | Details for djangorestframework-more-1.5.0.tar.gz |
Release files / djangorestframework-more-1.5.0.tar.gz
| Download URL | djangorestframework-more-1.5.0.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6ff41e8a8917541386fc0edd8883832bf034642fdf3b8990b039421ed8e7337f
|
|
BLAKE2b-256 checksum How to use checksums |
13820900be4e8e91334456c2ffb86017fd7c40bc478adfca4af383fc1b61002f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/26.0 requests/2.24.0 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.49.0 importlib-metadata/4.0.1 keyring/21.4.0 rfc3986/1.4.0 colorama/0.4.3 CPython/3.8.5
|
Security for djangorestframework-more 1.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.