'Django form request method is always GET
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.
Solution 1:[1]
There is no action mentioned in your form. View function needs to be modified to keep it simple and readable.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | B.Anup |

