[Answered ]-Django tags and html buttons


Django variables are rendered from the server side, so you can not change the variable after it was passed to your template. What you want to achieve is done via frontend scripting.

In this case you would pass both variables to the django template, save them in your Javascript and then switch them once you clicked the button you mentioned (via onClick event handling).


You can use url arguments like:



then, in your views.py you can use request.POST[‘show2’] to check if exists and then send a variable again to the view to be checked with your {if}s

As an aside note, either you don’t understand basic request flow with web applications or you are not explaining properly what you mean with “html button”, so you are not fluent with html language. Sorry if my intuition is harsh or wrong.


its not that clear what you are asking but here is how to make the logic work as I think you want it based on yoru submitted code:

in your template change it to
ifequal alterprofile "no"
to include registration/submittedprofile.html.

When you change the view to alterprofile = "yes" the registration/submittedprofile2.html will be included instead if you keep your current template logic.

This is because in your view, alterprofile is assigned a string therefore its always a string. When you tried to test against no instead of "no" django was looking for a variable called no which doesn’t exist.

This means that everytime you run it would have always included registration/submittedprofile2.html

Leave a comment