I need to change the Django variables from my templates.
for example, I have a variable named {{ fof_list.3.view_count}} and every time I click in an specific button, i need to increase this variable, like:
{{ fof_list.3.view_count}} += 1;
Is that possible? How to achieve that?
The template language won’t let you do that. You’ll need to setup an ajax request that fires everytime the button is pressed and increments the view count.
Here’s example of how you’d hook that all up (completely untested)
HTML:
Jquery:
View: