drf-renderer-xlsx | XLSX spreadsheet renderer for Django REST | Data Visualization library
kandi X-RAY | drf-renderer-xlsx Summary
kandi X-RAY | drf-renderer-xlsx Summary
An XLSX spreadsheet renderer for Django REST Framework.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Render a report .
- Flattens the serializer s fields .
- Flattens the data into a nested list .
- Create a named style from a dictionary .
- Get the value of a property from a given object .
- Add the filename to the response .
- Get filename .
drf-renderer-xlsx Key Features
drf-renderer-xlsx Examples and Code Snippets
class MyExampleViewSet(XLSXFileMixin, ReadOnlyModelViewSet):
queryset = MyExampleModel.objects.all()
serializer_class = MyExampleSerializer
renderer_classes = (XLSXRenderer,)
column_header = {
'titles': [
"Column_
pip install drf-renderer-xlsx
REST_FRAMEWORK = {
...
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
'rest_framework.renderers.BrowsableAPIRenderer',
'drf_renderer_xlsx.
xlsx_custom_mappings = {
'status': 'display'
}
def reverse_text(val):
return val[::-1]
xlsx_custom_mappings = {
'description': reverse_text
}
Community Discussions
Trending Discussions on drf-renderer-xlsx
QUESTION
I'm setting up an endpoint on my API which should return a XLSX-file. The DRF-docs mention https://github.com/wharton/drf-renderer-xlsx as the main external rendering package, aside from the pandas which also seem to be able to render XLSX.
In their code example they use a ReadOnlyViewset paired with a mixin, but there is no mention of how it's used with APIViews. Still, I would like to use an APIView as shown by this https://harshahegde.dev/rendering-xlsx-files-in-django-rest-framework-ckagk293p00eumks1bf4dlhie However.. This works great when using CURL or Postman, but when done through a browser I get this error:
...ANSWER
Answered 2021-Jan-23 at 23:59Looking at the mixin code it became clear they change the content-disposition header, and so since the DRF Response() takes a header argument I tried changing it, and it worked perfectly.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install drf-renderer-xlsx
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page