1๐
โ
Try this:
def name(request):
if request.method == 'POST':
form = VartotojasForm(request.POST)
if form.is_valid():
name = form.cleaned_data['name']
surname = form.cleaned_data['surname']
return render(request, 'vartotojas-result.html', {'form': form, 'name': name, 'surname': surname })
else:
form = VartotojasForm()
return render(request, 'vartotojas-form.html', {'form': form})
Also in render parameters , your names
variable is undefined:
{'form': form, 'name': names, 'surname': surname }
change it to name
:
{'form': form, 'name': name, 'surname': surname }
And change your Vartotojas-form.html
form to:
<html>
<head>
<title>Name</title>
</head>
<body>
<h1>Name</h1>
<form action="sumbit" method="post">
<table>
{{ form.as_table }}
</table>
{% csrf_token %}
<input type="submit" value="Submit">
</form>
</body>
๐คOmid Raha
0๐
Make sure your template uses name parameter in the input tag
<input type="text" name="surname" value="">
<input type="text" name="name" value="">
and that the fields in Django form match the fields in html form
๐คfragles
Source:stackexchange.com