Reputation: 367
I'm learning django with v1.8 and I'm trying to create a form, but submit doesn't work and I don't have error.. If someone can help me, it will be very nice. Thank you
views.py
from django.shortcuts import render, redirect
from django.contrib.auth.forms import UserCreationForm
from django.shortcuts import render
def register(request):
if request.method == "POST" :
form = UserCreationForm(request.POST)
if form.is_valid():
form.save()
return redirect('/account')
else:
form = UserCreationForm()
args = {'form': form}
return render(request, 'polls/register.html', args)
register.htlm
{% block content %}
<form action="polls/register.html" method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="button">button</button>
</form>
{% endblock %}
Upvotes: 0
Views: 204
Reputation: 88499
Change button type
tag to input
{% block content %}
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Submit">
</form>
{% endblock %}
Upvotes: 1