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

handle errors rendering with TemplateHTMLRenderer #742

Conversation

terencehonles
Copy link
Contributor

This change fixes an OPTIONS request to the API page which will return a successful response, but the TemplateHTMLRender will not be prepared to render it since there is no template name provided in either the view or response.

This change fixes an `OPTIONS` request to the API page which will return
a successful response, but the `TemplateHTMLRender` will not be prepared
to render it since there is no template name provided in either the view
or response [1].

[1]: https://github.com/encode/django-rest-framework/blob/f0a5b958a134e8cd94e3ef3263e8fa623ac9b82f/rest_framework/renderers.py#L178-L189
# see https://github.com/axnsan12/drf-yasg/issues/58
return TemplateHTMLRenderer().render(swagger, accepted_media_type, renderer_context)
except ImproperlyConfigured:
# Fall back to using eg '404 Not Found'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JoelLefkowitz JoelLefkowitz changed the base branch from master to 1.20.x September 24, 2021 06:46
@JoelLefkowitz JoelLefkowitz added bug Bug report/fix 1.20.x Release target in 1.20.x labels Sep 24, 2021
@JoelLefkowitz JoelLefkowitz added 1.21.x Release target in 1.21.x and removed 1.20.x Release target in 1.20.x labels Jul 17, 2022
@JoelLefkowitz JoelLefkowitz changed the base branch from 1.20.x to 1.21.x July 17, 2022 17:08
@JoelLefkowitz JoelLefkowitz merged commit f87dbd5 into axnsan12:1.21.x Jul 18, 2022
@terencehonles terencehonles deleted the handle-errors-rendering-with-TemplateHTMLRenderer branch July 18, 2022 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.21.x Release target in 1.21.x bug Bug report/fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants