creating my own context processor in django

后端 未结 4 1989
青春惊慌失措
青春惊慌失措 2020-11-29 00:01

I have come to a point where I need to pass certain variables to all of my views (mostly custom authentication type variables).

I was told writing my own context pro

4条回答
  •  北荒
    北荒 (楼主)
    2020-11-29 00:51

    If you’re using Django’s render_to_response() shortcut to populate a template with the contents of a dictionary, your template will be passed a Context instance by default (not a RequestContext). To use a RequestContext in your template rendering, use the render() shortcut which is the same as a call to render_to_response() with a context_instance argument that forces the use of a RequestContext.

提交回复
热议问题