This is the html code:
<form method='POST'>{% csrf_token %}
{{ form.as_p }}
<input type='submit' value='save'/>
</form>
This is the path in url.py:
path('student/create/', student_create_view, name='student-create')
This is my code in views.py:
def student_create_view(request):
form = StudentForm(request.POST or None)
if form.is_valid():
form.save()
form = StudentForm
context = {
'form': form
}
return render(request, "personnel/student_create.html", context)
I also tried using action attribute and adding or removing "/" to the end of the path.
CodePudding user response:
There is no action mentioned in your form. View function needs to be modified to keep it simple and readable.