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.6.tar.gz (38.0 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for django-spreadsheetresponsemixin-0.1.6.tar.gz
Algorithm Hash digest
SHA256 23bf886562a464cb052b6722cdac2ffd26fc115d7435c11653915d2e68ad3948
MD5 f10e6edb572d2efcedc283adc90ccf9c
BLAKE2b-256 6c7b3e99999626c26f7afa221e09e88cec55ac7021d2e1588e973d6a2c4ddd94

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