Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ settings the ``filename`` attribute. There is a corresponding
By default, ``CsvView`` will output the headers as the first line. If you
want to suppress this behavior, set ``output_headers`` to ``False``.

By defaultm ``csv.excel`` is used as the dialect. You can override the by setting
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default,

the ``dialect`` attribute. For example::

class UserCsvView(CsvView):
model = User
dialect = csv.excel_tab

separated.views.CsvResponseMixin
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
3 changes: 2 additions & 1 deletion separated/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class CsvResponseMixin(MultipleObjectMixin):
columns = None
output_headers = True
filename = '{model_name}_list.csv'
dialect = csv.excel

def render_to_response(self, context, **kwargs):
queryset = context['object_list']
Expand All @@ -46,7 +47,7 @@ def render_to_response(self, context, **kwargs):
filename=self.get_filename(model),
)

writer = csv.writer(response)
writer = csv.writer(response, dialect=self.dialect)

if self.output_headers:
writer.writerow(self.get_header_row(model))
Expand Down