A potential option if you're not ready to dig deep into javascript is to look into HTMX.
You can just create a django view with whatever python functionality you want, and use HTMX to perform a get or post call to it. Here I'm just returning a chunk of html that will be inserted into the dataLocation div, but you could literally call anything that's possible with python from your view and return useful html.
index.html
<button hx-get="/alert_message/" hx-target="#dataLocation" hx-swap="innerHTML">
Click Me
</button>
<div id="dataLocation"></div>
views.py
from django.http import HttpResponse
def alert_message(request):
return HttpResponse(
(
"<div class='alert alert-warning'>"
" <strong>Warning!</strong> Some important message."
"</div>"
),
status=200,
content_type="text/html",
)
urls.py
urlpatterns = [
path('alert_message/', views.alert_message, name='alert_message'),
]