Skip to main content

An mixin for views with a queryset that provides a CSV/Excel export.

Project description

django-spreadsheetresponsemixin

View mixin for django, that generates a csv or excel sheet.

Usage

Add to your django view as a mixin:

class ExcelExportView(SpreadsheetResponseMixin, ListView):
    def get(self, request):
        self.queryset = self.get_queryset()
        return self.render_excel_response()


class CsvExportView(SpreadsheetResponseMixin, ListView):
    def get(self, request):
        self.queryset = self.get_queryset()
        return self.render_csv_response()

Note you must specify a Queryset, ValuesQueryset or ValuesListQueryset on the class or pass it in when you call the render method.

You can also specify the fields and the headers as tuples if you want to refine the results and / or provide custom headers for your columns

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

django-spreadsheetresponsemixin-0.1.3.tar.gz (37.9 kB view details)

Uploaded Source

File details

Details for the file django-spreadsheetresponsemixin-0.1.3.tar.gz.

File metadata

File hashes

Hashes for django-spreadsheetresponsemixin-0.1.3.tar.gz
Algorithm Hash digest
SHA256 627ba03f93e43d0100058b73405b3cfbcdb2491232f10980e73b86e391f26a2d
MD5 a8b66ed6b292e78c05ba20d1f323416e
BLAKE2b-256 d0d03758162ce07778d3cc049474322092abf5e3752cefd9a80b9441fd8a3f27

See more details on using hashes here.

Provenance

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