def process_response(self, request, response):
        view_name = get_used_view_name(request)
        if view_name:
            response['X-View'] = view_name

        template_name, choices = get_used_template(response)
        if template_name:
            if choices:
                response['X-View-Template'] = '{0}   (out of: {1})'.format(template_name, ', '.join(choices))
            else:
                response['X-View-Template'] = template_name
        return response
    def process_response(self, request, response):
        view_name = get_used_view_name(request)
        if view_name:
            response['X-View'] = view_name

        template_name, choices = get_used_template(response)
        if template_name:
            if choices:
                response['X-View-Template'] = '{0}   (out of: {1})'.format(
                    template_name, ', '.join(choices))
            else:
                response['X-View-Template'] = template_name
        return response
示例#3
0
    def process_response(self, request, response):
        view_name = get_used_view_name(request)
        if view_name:
            response["X-View"] = view_name

        template_name, choices = get_used_template(response)
        if template_name:
            if choices:
                response["X-View-Template"] = "{0}   (out of: {1})".format(
                    template_name, ", ".join(choices)
                )
            else:
                response["X-View-Template"] = template_name
        return response
示例#4
0
    def process_response(self, request, response):
        # See if more information can be read from the TemplateResponse object.
        view_object = None
        template, choices = get_used_template(response)
        if template and getattr(response, "context_data", None):
            view_object = response.context_data.get("view")
            if not isinstance(view_object, View):
                view_object = None

        self.record_stats(
            {
                "view_module": self.view_module,
                "view_name": self.view_name,
                "view_data": self._get_view_data(view_object),
                "template": template,
                "template_choices": choices,
            }
        )
示例#5
0
    def process_response(self, request, response):
        # Find out what template was used.
        template, choices = get_used_template(response)

        # See if more information can be read from the TemplateResponse object.
        if template and getattr(response, "context_data", None):
            context_data = response.context_data
        else:
            context_data = None

        self.record_stats(
            {
                "view_module": self.view_module,
                "view_name": self.view_name,
                "view_data": self._get_view_data(context_data) if context_data else None,
                "template": template,
                "template_choices": choices,
            }
        )
示例#6
0
    def process_response(self, request, response):
        # Find out what template was used.
        template, choices = get_used_template(response)

        # See if more information can be read from the TemplateResponse object.
        if template and getattr(response, 'context_data', None):
            context_data = response.context_data
        else:
            context_data = None

        self.record_stats({
            'view_module':
            self.view_module,
            'view_name':
            self.view_name,
            'view_data':
            self._get_view_data(context_data) if context_data else None,
            'template':
            template,
            'template_choices':
            choices,
        })