Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bug on render() method concerning renderer_context #321

Closed
@erichaus

Description

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

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

        AltStyle によって変換されたページ (->オリジナル) /