Django DetailView - how to use 'request' in get_context_data

前端 未结 1 997
一整个雨季
一整个雨季 2020-12-24 04:47

I am trying to modify context data, so I overrided get_context_data. I need the request variable to modify this context. So how can I get the

相关标签:
1条回答
  • 2020-12-24 05:28

    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.

    0 讨论(0)
提交回复
热议问题