Shivendra,
If you want to have an effect at the server without leaving the
current page, you'll find that Django itself does not do that.
Instead, you'll have to do one of:
- Use JavaScript in the page to make an Ajax or WebSockets
call to the server (handled by a Django view if you like) to tell
it to update the DB, or...
- Use Django "Channels" to communicate with the server via
WebSockets.
If you find yourself doing lots of Ajax calls to the server, you may
want to check out the Django REST Framework which makes it
easier to write Django views that accept Ajax calls and return
JSON data instead of returning full HTML pages.
Or, you can accomplish a similar effect via plain vanilla Django,
if you allow the button click to trigger a regular form submit, and
have the response look exactly like the original page, so it's not
obvious to the user that a full page request was done. But, it
sounds like you've already decided you don't want to do that.