1👍
✅
I don’t think that having extra=0
is related to whether the errors are displayed.
The following pattern is very common when dealing with formsets:
def my_view(request):
if request.method == "POST"
formset = MyFormSet(request.POST, prefix="coding_form")
if formset.is_valid():
do_something_with_formset()
return HttpResponseRedirect("/success_url/")
else:
formset = MyFormSet(request.POST, prefix="coding_form")
return render(request, "my_template.html", {'formset': formset}
When the request method is GET, a blank formset is rendered. When the formset is invalid, the formset is rendered, and will display the errors. We only redirect if the formset is valid.
In your case, you always redirect when the request method is POST, regardless of whether the formset is valid or not. Therefore, you’ll never see the errors when formset is invalid.
Source:stackexchange.com