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

Only call render on the response if it has a render method #10506

Closed
sentry-io bot opened this issue Apr 18, 2023 · 3 comments · Fixed by #11762
Closed

Only call render on the response if it has a render method #10506

sentry-io bot opened this issue Apr 18, 2023 · 3 comments · Fixed by #11762
Assignees

Comments

@sentry-io
Copy link

sentry-io bot commented Apr 18, 2023

AttributeError: 'HttpResponseNotAllowed' object has no attribute 'render'

Sentry Issue: KOLIBRI-BACKEND-2BQ

AttributeError: 'HttpResponseNotAllowed' object has no attribute 'render'
(3 additional frame(s) were not displayed)
...
  File "django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "django/utils/decorators.py", line 67, in _wrapper
    return bound_func(*args, **kwargs)
  File "django/views/decorators/http.py", line 99, in inner
    response = func(request, *args, **kwargs)
  File "kolibri/core/decorators.py", line 374, in inner_func
    render_and_cache(response, CACHE_KEY_TEMPLATE.format(request.path))
  File "kolibri/core/decorators.py", line 342, in render_and_cache
    response.render()
@rtibbles rtibbles added this to the 0.16 Future Patches triage milestone Apr 18, 2023
@KshitijThareja
Copy link
Contributor

KshitijThareja commented Jan 21, 2024

@rtibbles It's just a simple fix according to me. We just have to check whether the response object has the render attribute or not before calling response.render() in the render_and_cache function. Could you please assign this issue to me?
Thanks :)

@rtibbles
Copy link
Member

Yes, checking it has the attribute render and that it is callable should be good, see a similar example here https://github.com/learningequality/kolibri/blob/release-v0.16.x/kolibri/core/content/api.py#L135

@MisRob
Copy link
Member

MisRob commented Feb 23, 2024

Closed by #11762

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

Successfully merging a pull request may close this issue.

3 participants