django DetailView - 如何在get_context_data中使用'request' [英] django DetailView - how to use 'request' in get_context_data
问题描述
你可以访问 self.request
- 第三段这里再说一遍。
编辑:文字被提到,万一它改变了:
这个工作的关键部分是当基于类的视图被调用时,各种有用的东西被存储在自;以及请求(self.request),它包括根据URLconf捕获的位置(self.args)和基于名称的(self.kwargs)参数。
I am trying to modify context data, so I overrided get_context_data. I need 'request' variable for modify this context. So, how can i get 'request' variable in get_context-data ?
You have access to the request in self.request
- the third paragraph here explains a little more.
EDIT: The text referred to, in case it changes:
The key part to making this work is that when class-based views are called, various useful things are stored on self; as well as the request (self.request) this includes the positional (self.args) and name-based (self.kwargs) arguments captured according to the URLconf.
这篇关于django DetailView - 如何在get_context_data中使用'request'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!