S
S
smsi2019-11-01 13:29:44
Django
smsi, 2019-11-01 13:29:44

How to display the {{ value}} variable in a Django template only when a menu item is clicked?

Good day
There is a menu, something like this:

<li class="hassubs">
                                        <a href="#">Select<i class="fas fa-chevron-down"></i></a>
                                        <ul>
                                            <li><a href="#"> Value_1{{ set_value_1}} </a></li>
                                            <li><a href="#"> Value_2{{ set_value_2}} </a></li>
                                        </ul>
                                    </li>

It is necessary that {{ set_value_1}} and {{ set_value_2}} are displayed (calculated) only when clicking on the corresponding menu item.
(in fact, when calling {{ set_value_1}} and {{ set_value_2}}, they save the values ​​of the variables to the session, while one is available through the context processor, but this probably does not affect the essence of the issue
def set_value_1(self):
        self.currency['var']= 'var1'
        self.session.modified = True
    def set_value_2(self):
        self.currency['var']= 'var2'
        self.session.modified = True

)
How can I make it so that {{ set_value_1}} and {{ set_value_2}} are called only when clicking on the corresponding menu item?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2019-11-01
@smsi

How to do a button click check in django?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question