Skip to main content

A Django REST Framework package allowing views to be rendered as CSV or XLSX

Project description

Django REST Spreadsheets renderer

This project pulls work from drf-renderer-xlsx and django-rest-framework-csv aiming to combine these renders into a single package while fixing some of their individual quirks.

Differences

An important use case for file export in a RESTful API is to allow the user to manipulate data using their own tools. While pagination is useful for endpoints where you don't need to see all the data, they don't make sense for these types of file export. This project will handle pagination by ignoring it, serializing the entire queryset.


In addition, to enable CSV/XLSX on an endpoint, all that needs to be done is adding a single mixin like such:

from drf_spreadsheets.mixins import SpreadsheetMixIn

class YourViewSet(SpreadsheetMixIn, ModelViewSet):
    ...

This instead of manually overriding renderer_classes, or adding the renderer to the defaults. The former is clunky and can lead to unwanted behavior and the latter is rarely necessary since there will be many endpoints that don't need spreadsheet exports in most projects.


One regression is in XLSX styling. For the initial version of this package, no styling can be applied to generated XLSX files. Since this is not an essential feature for most export use-cases, it has been left as a potential future feature

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

drf-spreadsheets-jpaavola-1.0.0.tar.gz (4.3 kB view hashes)

Uploaded Source

Built Distribution

drf_spreadsheets_jpaavola-1.0.0-py3-none-any.whl (6.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page