tcms.core.response module

class tcms.core.response.ModifySettingsTemplateResponse(request, template, context=None, content_type=None, status=None, charset=None, using=None)[source]

Bases: django.template.response.TemplateResponse

A response class which knows how to modify settings while rendering. The attribute modify_settings must be assigned to a django.test.utils.modify_settings instance before calling render(). For example:

from django.test.utils import modify_settings

class MyView(TemplateView):
    response_class = ModifySettingsTemplateResponse

    def render_to_response(self, context, **response_kwargs):
        self.response_class.modify_settings = modify_settings(...)
        return super().render_to_response(context, **response_kwargs)


The reason we need this class is because when using class based views Django supports delayed rendering. Which means modifying settings in the view class will not work because rendering happens later in the cycle.

modify_settings = None

Render (thereby finalizing) the content of the response.

If the content has already been rendered, this is a no-op.

Return the baked response instance.