﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34830	csrf_failure and bad_request views missing context processors	Alex Henman	yushan	"The default `csrf_failure` view does not pass the request to the template rendering engine which means that all context processors are missing.

This is problematic if you override the default `403_csrf.html` template without customising the view and are expecting the same default context you would get access to in other templates.

----

I think the most straight forward way to replicate on a default Django deployment would be to add a custom `403_csrf.html` template to your templates dir and attempt to access from some of Django's built-in context processors e.g. `request` or `TIME_ZONE`

----

The fix should be very straight forward unless there's a good reason not to pass the request to the template engine in this view. The view currently looks like this:

{{{
#!python
def csrf_failure(request, reason="""", template_name=CSRF_FAILURE_TEMPLATE_NAME):
    """"""
    Default view used when request fails CSRF protection
    """"""
    from django.middleware.csrf import REASON_NO_CSRF_COOKIE, REASON_NO_REFERER

    c = {
        ""title"": _(""Forbidden""),
        ...
    }
    try:
        t = loader.get_template(template_name)
    except TemplateDoesNotExist:
        if template_name == CSRF_FAILURE_TEMPLATE_NAME:
            # If the default template doesn't exist, use the fallback template.
            with builtin_template_path(""csrf_403.html"").open(encoding=""utf-8"") as fh:
                t = Engine().from_string(fh.read())
            c = Context(c)
        else:
            # Raise if a developer-specified template doesn't exist.
            raise
    return HttpResponseForbidden(t.render(c))
}}}

So it just needs modifying to `t.render(c, request)`"	Bug	closed	Core (Other)	dev	Normal	fixed		David Wobrock	Ready for checkin	1	0	0	0	1	0
