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

Uploaded Source

File details

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

File metadata

File hashes

Hashes for django-spreadsheetresponsemixin-0.1.7.tar.gz
Algorithm Hash digest
SHA256 506e25eeba012ddeaca2c06056dbcb546e93b589a0059b64105d17d4f3aec961
MD5 e3a11deba708191c2b829486204502df
BLAKE2b-256 c87f5e6aacb5e99c8e8b0766a9c8dc88f3130e884ea81c471c902fa9274d0c70

See more details on using hashes here.

Supported by

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