Skip to content

Bug on render() method concerning renderer_context #321

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

Closed
erichaus opened this issue Feb 5, 2017 · 1 comment
Closed

Bug on render() method concerning renderer_context #321

erichaus opened this issue Feb 5, 2017 · 1 comment

Comments

@erichaus
Copy link

erichaus commented Feb 5, 2017

Hello, we are using this package and ran into an issue with our unit tests where it seems that the rest_framework APIRequestFactory which is behind the test client does not pass in a renderer_context:

    def render(self, data, accepted_media_type=None, renderer_context=None):

>       view = renderer_context.get("view", None)
E       AttributeError: 'NoneType' object has no attribute 'get'

/usr/local/lib/python3.5/site-packages/rest_framework_json_api/renderers.py:419: AttributeError

I think you could fix it by doing renderer_context={}

The code from this library will break at the following lines which are not guarded properly:

https://github.com/django-json-api/django-rest-framework-json-api/blob/develop/rest_framework_json_api/renderers.py#L419

also:
https://github.com/django-json-api/django-rest-framework-json-api/blob/develop/rest_framework_json_api/renderers.py#L401
https://github.com/django-json-api/django-rest-framework-json-api/blob/develop/rest_framework_json_api/renderers.py#L420

Here is the corresponding rest_framework.test line that you can see does not include renderer_context as an argument:

https://github.com/tomchristie/django-rest-framework/blob/master/rest_framework/test.py#L183

Let me know if this makes sense or if I'm off course!

Thanks

@sliverc
Copy link
Member

sliverc commented May 22, 2018

This should have been fixed with #396 hence closing this issue. If there are still issues concerning this error, please comment.

@sliverc sliverc closed this as completed May 22, 2018
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