[Fixed]-Onclick auto executing in django template

1👍

You have not understood the distinction between front-end and back-end code.

onclick is a Javascript event handler. It should contain JS code that executes on the frontend.

Django template language executes on the backend. It is called at render time, when the user first requests the page, not when they interact with it.

The way to do this is to write a JS function that uses Ajax to call a Django view which updates the visible status.

Leave a comment