There are four pages: Blog, Tags, About the program, Feedback , two of them are generated through and they are transmitted through render_to_response() " this_page ", and two through DetailView .

In general: is it possible to somehow convey the " this_page " through the DetailView or how to do it differently.

 <ul class="nav"> <li class="{% if this_page == "blog" %}active{% endif %}"> <a href="/blog"> Блог<br> </a> </li> <li class="{% if this_page == "tags" %}active{% endif %}"> <a href="/tags"> Теги<br> </a> </li> <li class="{% if this_page == "about" %}active{% endif %}"> <a href="/about"> О программе<br> </a> </li> <li class="{% if this_page == "contact" %}active{% endif %}"> <a href="/about"> Обратная связь<br> </a> </li> </ul> 

    1 answer 1

    Try this:

     class MyModelDetailView(DetailView): model = MyModel def get_context_data(self, **kwargs): context = super(MyModelDetailView, self).get_context_data(**kwargs) context['this_page'] = 'about' # 'contact' return context ...