You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.rst
+22-1Lines changed: 22 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,7 @@ Run::
31
31
32
32
pip install django-queryset-csv
33
33
34
-
Supports Python 2.6 and 2.7, Django 1.5and 1.6.
34
+
Supports Python 2.6 and 2.7, Django 1.5, 1.6, and 1.7.
35
35
36
36
usage
37
37
-----
@@ -69,3 +69,24 @@ views.py::
69
69
def csv_view(request):
70
70
people = Person.objects.values('name', 'favorite_food__name')
71
71
return render_to_csv_response(people)
72
+
73
+
keyword arguments
74
+
-----------------
75
+
76
+
This module exports two functions that write CSVs, ``render_to_csv_response`` and ``write_csv``. Both of these functions require their own positional arguments. In addition, they both take three optional keyword arguments:
77
+
78
+
* ``field_header_map`` - (default: ``None``) A dictionary mapping names of model fields to column header names. If specified, the csv writer will use these column headers. Otherwise, it will use defer to other parameters for rendering column names.
79
+
* ``use_verbose_names`` - (default: ``True``) A boolean determining whether to use the django field's ``verbose_name``, or to use it's regular field name as a column header. Note that if a given field is found in the ``field_header_map``, this value will take precendence.
80
+
* ``field_order`` - (default: ``None``) A list of fields to determine the sort order. This list need not be complete: any fields not specified will follow those in the list with the order they would have otherwise used.
81
+
82
+
The remaining keyword arguments are *passed through* to the csv writer. For example, you can export a CSV with a different delimiter::
83
+
84
+
views.py::
85
+
86
+
from djqscsv import render_to_csv_response
87
+
88
+
def csv_view(request):
89
+
people = Person.objects.values('name', 'favorite_food__name')
0 commit comments