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.md
+9-1
Original file line number
Diff line number
Diff line change
@@ -56,14 +56,22 @@ Here, our `fetch_records` is just spitting the data straight to the headers for
56
56
57
57
Note that we specify the type of the header for`headers`. This allows the typechecker to find out quickly ifany of your headers are accessing data incorrectly.
58
58
59
-
Now, we can use it. We have two methods for getting data out -`to_list`and`as_response`. `to_list` will convert the data to a list of lists of strings (allowing you to pass it to whatever other CSV handling options you want) whereas `as_response` will turn it into a prepared HttpResponse for returning from one of your views
59
+
Now, we can use it. We have several methods for getting data out:
60
+
61
+
`to_list` will convert the data to a list of lists of strings (allowing you to pass it to whatever other CSV handling options you want):
60
62
61
63
```python
62
64
LlamaExporter(my_llamas).to_list()
65
+
```
66
+
67
+
whereas `as_response` will turn it into a prepared HttpResponse for returning from one of your views:
63
68
69
+
```python
64
70
LlamaExporter.as_response('my_llamas')
65
71
```
66
72
73
+
If your CSVis large, and takes a long time to generate, you should use a generator, or stream the response. `to_iter`and`to_streamed_response` are the generator_counterparts to the above methods, working in exactly the same way, just returning a generator and a `HttpStreamedResponse` respectively. By default, `to_list` calls `to_iter`, so if you need to do anything custom, it's best to do it in `to_iter`.
74
+
67
75
You can also provide an ordering to the headers, if you want. Simply assign a list of strings to `header_order`and when the data is unpacked, those headers who's labels match these will be placed in that order.
0 commit comments