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

Uploaded Source

File details

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

File metadata

File hashes

Hashes for django-spreadsheetresponsemixin-0.1.4.tar.gz
Algorithm Hash digest
SHA256 0d7499a5d0aeafc24a9bc71de8144946fabfbeca4429f62ea0d576d1a3516181
MD5 2c177ecb505da78c9f8a1f94c079ab66
BLAKE2b-256 30daae268ceae1453b28cb4c335c629e23938675987e2c66096e87a59afa72ff

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