A 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.
Exported file will be named export.csv or export.xlsx by default, but you can change this by either specifying export_filename attribute to name exported file or export_filename_root to specify only the root part of it (and let app take care of the appropriate extension).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for django-spreadsheetresponsemixin-0.1.9.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0cf8ce2a435f98349a16c04c6a8fd667079cb5fddc4939f191d3e3c0356f7075 |
|
MD5 | 5d425af236692453af8de0249e21c36c |
|
BLAKE2b-256 | 66531da2d8d73eca138d7487b202fdf3d69a47d8196f13214b569ee367444664 |