﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
30404	"""Using a model formset in a view"" example doesn't handle invalid formset."	Stephen G Tuggy	nobody	"The URL is here: [https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a-model-formset-in-a-view] The 2.2 and 1.8 documentation versions suffer from the same problem (and probably every other version in between).

You will notice that the Method-Based View `manage_authors` handles the case where `request.method == 'POST'` and `formset.is_valid()`, but **not** the case where `request.method == 'POST'` and `formset` is not valid. As a result, newbies (like myself) following this example may not implement this case either. Then, if the data POSTed to this view passes client-side validation but not server-side validation, the user will get an error message:

`The view '...' didn't return an HttpResponse object. It returned None instead`

See this StackOverflow post, for example: [https://stackoverflow.com/questions/50202477/the-view-blog-views-post-list-didnt-return-an-httpresponse-object-it-returned?rq=1] And this post: [https://www.freecodecamp.org/forum/t/didnt-return-an-httpresponse-object-it-returned-none-instead/216155/2]

As far as I have been able to determine, the correct code behavior in this situation is pretty much the same as what you do for a GET: Construct a context dictionary, starting with RequestContext, then return the result of rendering the formset once more. One caveat: Make sure your template has a spot to display non-field errors.

Is this correct? Thank you for your attention."	Cleanup/optimization	closed	Documentation	dev	Normal	worksforme			Unreviewed	0	0	0	0	0	0
