Skip to content

Calling PandasBaseRenderer().render(data) throws TypeError #34

Closed
@arthurio

Description

@arthurio

For personal reasons, I wanted to call the PandasCSVRenderer on a dataframe outside of a view.

Because renderer_context is defaulted to None, the following code will throw TypeError: argument of type 'NoneType' is not iterable:

from rest_pandas import renderers


data_frame = pandas.DataFrame(some_data)
print renderers.PandasCSVRenderer().render(data_frame)
>>>TypeError: argument of type 'NoneType' is not iterable

I suggest two options to fix the following code:

if 'response' in renderer_context:

  1. Change the if statement:
if renderer_context and 'response' in renderer_context:
  1. Add the following at the top of the function:
if renderer_context is None:
    renreder_context = {}
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions