Skip to content

Conversation

satayyeb
Copy link

@satayyeb satayyeb commented Jan 5, 2024

refs #9209
Fixes #9209

Description

According to this documentation, the RequestContext should have status_code and details keys. so I changed the get_template_context function to set these keys in the context.

@auvipy auvipy self-requested a review March 6, 2024 14:41
@sevdog
Copy link
Contributor

sevdog commented Mar 6, 2024

A test to ensure the correct behaviour will complete this PR, I wrote one in #9209 which could be added.

@codespearhead
Copy link

Also, can you link this PR to that issue ( #9209 )?

@sevdog
Copy link
Contributor

sevdog commented Jun 28, 2024

@satayyeb could you please add the testcase from #9209 to ensure that this change resolves that issue?

class StaticHTMLRendererErrorTests(URLPatternsTestCase):
    class StaticErrorView(APIView):
        renderer_classes = (StaticHTMLRenderer,)

        def get(self, request, **kwargs):
            raise exceptions.ValidationError('error')

    urlpatterns = [path('error', StaticErrorView.as_view())]

    def test_statis_renderer_with_api_exception(self):
        response = self.client.get('/error')  # this line raise a TypeError
        assert response.status_code == 400

The test is important to ensure that we do not fell into the same issue again.

Copy link
Contributor

@auvipy auvipy left a comment

Choose a reason for hiding this comment

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

replaced by another PR with tests. thanks for the initial fix!

@auvipy auvipy closed this Jul 15, 2024
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 this pull request may close these issues.

StaticHTMLRenderer cannot handle ValidationError
4 participants