I'm trying to make a basic function in Django, but I don't know how to call the function in views.py
from the template when a button is clicked.
I did find a similar question here.
But actionUrl
confused me a lot, and I am not sure how to implement it.
Button code in template:
<form action ="{% check1 %}" method = "POST">
{% csrf_token %}
<button type='submit'> True</button>
</form>
Currently I have commented out the actual logic of the function and am just trying to get it to respond so it's here:
def check1(request):
return HttpResponse("why u no work")
urls.py
:
urlpatterns = [
path('', Posts, name='Posts'),
path('', index, name = 'index'),
path('', check1, name = 'check1'),
#path(actionUrl, views.check1),
]