django-rest-framework-csv icon indicating copy to clipboard operation
django-rest-framework-csv copied to clipboard

Potential compatibility issue / style improvement

Open IvanAnishchuk opened this issue 6 years ago • 1 comments
trafficstars

render method on the main renderer is defined like this: def render(self, data, media_type=None, renderer_context={}, writer_opts=None): here which is both not how other renderers are defined and has a mutable object as a default value which is discouraged and could be dangerous.

I suggest we update it to something closer to other examples in DRF: def render(self, data, accepted_media_type=None, renderer_context=None). I'll prepare a PR if there are no volunteers or objections.

IvanAnishchuk avatar Jul 12 '19 11:07 IvanAnishchuk

While at it, streaming renderer's result is not displayed correctly in browsable api. Instead something like this is shown: <generator object CSVStreamingRenderer.render at 0x7f773d04ff10> perhaps some more sophisticated object can be used there, something that can be rendered into django template if needed but otherwise behaving like a generator?

IvanAnishchuk avatar Jul 15 '19 15:07 IvanAnishchuk