Anthony
Anthony

Reputation: 959

Delete Session Data From Django Template

Basically, I want the user to be able to click a button in the template that will invoke

del request.session['example'] 

which is in my views.py

So maybe something like.

if *user has pressed button*:
   del request.session['example']

else:
   pass

I can't figure out how to communicate this between my template and my views

Upvotes: 0

Views: 325

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599540

Any interaction between the user and Django must be done via a URL and a view. In your case, you can have a form the user submits manually, or if you want it to be more seamless you can use Ajax, but either way the principle is the same: the user invokes some action that calls a view by making a request to a URL.

Upvotes: 1

Related Questions