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

Uploaded Source

File details

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

File metadata

File hashes

Hashes for django-spreadsheetresponsemixin-0.1.5.tar.gz
Algorithm Hash digest
SHA256 442a2a65121842d079a3e3ec06689ea81a8b282a98e0840394c4f9a1a615561c
MD5 34ecbb04b46adb36de6a68637fcae642
BLAKE2b-256 6ef3ffb6226bbf9ae2c535535b05b38feb2799c0a136e904f75aaaefc7db397a

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