Skip to content
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

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

Closed
arthurio opened this issue Mar 23, 2018 · 2 comments
Closed

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

arthurio opened this issue Mar 23, 2018 · 2 comments

Comments

@arthurio
Copy link

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 = {}
...
@sheppard
Copy link
Member

Thanks for the suggestion. This is fixed in v1.1.0

@arthurio
Copy link
Author

Thanks for closing the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants