-
Notifications
You must be signed in to change notification settings - Fork 42
Change render_to_csv_response to return a StreamingHttpResponse by default. #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ff2144c
to
1a5c1dd
Compare
render_to_csv_response
to return a StreamingHttpResponse
.fdbd9d3
to
6a023f9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good. Will try exercising the code a bit more tomorrow.
djqscsv/djqscsv.py
Outdated
else: | ||
response = StreamingHttpResponse( | ||
_iter_csv(queryset, _Echo(), **kwargs), | ||
content_type='text/csv') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider pulling content_type
out into a dict assigned to a variable and then unpacking it into HttpResponse()
and StreamingHttpResponse()
with **
.
from django.core.exceptions import ValidationError | ||
from django.utils.text import slugify | ||
from django.http import HttpResponse | ||
from django.http import HttpResponse, StreamingHttpResponse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I can tell, StreamingHttpResponse
is in all of the supported Django versions (even 1.6). We could probably drop support for 1.6 and 1.7 too, given that 1.7 is unsupported as of the end of Q4 2015.
See: https://www.djangoproject.com/download/#supported-versions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I dropped 1.5
because it was failing on Travis CI when run with Python 2.6
(not sure why, logs were broken last night).
Since 1.6
and 1.7
are no longer supported, I just dropped those as well, which let me get rid of some code too!
|
||
# add BOM to support CSVs in MS Excel (for Windows only) | ||
file_obj.write(b'\xef\xbb\xbf') | ||
yield file_obj.write(b'\xef\xbb\xbf') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice minimal change.
|
||
In addition to the above arguments, ``render_to_csv_response`` takes the following optional keyword argument: | ||
|
||
- ``streaming`` - (default: ``True``) A boolean determining whether to use ``StreamingHttpResponse`` instead of the normal ``HttpResponse``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think defaulting this to True
is fine, provided that we bump the major version number in the next release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I think the only thing left is to finalize the versions of Django we want to support.
6a023f9
to
e2ef154
Compare
@hectcastro Thanks for the review! I think this is ready to go, I'll merge it once all the tests pass. |
e2ef154
to
919b754
Compare
919b754
to
e98ac8f
Compare
Change
render_to_csv_response
to return aStreamingHttpResponse
instead of a normalHttpResponse
.The old behaviour is available by setting the keyword argument
streaming
toFalse
.This is technically a breaking change, as some middlewares do not work with
StreamingHttpResponse
.Also drops support for Python 2.6 and Django 1.5, and cleans up the README a bit.
Fixes #86, Fixes #87