Testing the validity of a form which has inline formsets from a View subclass

8 views
Skip to first unread message

Shaheed Haque

unread,
Sep 3, 2019, 8:11:35 PM9/3/19
to django...@googlegroups.com
Hi all,

I have a set of views in a superclass/subclass hierarchy like this:
  • mobile_view is a subclass of
  • generic___view is a subclass of
  • django-extra-views formset support view
As expected, the django-extra-views formset support's "post()" logic does a "if form.is_valid() then form.save(commit=False)", and then proceeds to save the contents of the formsets after testing them with formset "is_valid" logic, before returning an HttpResponse. AFAICS, no exceptions are raised to signal the error.

Let's say I now want to do some additional work in generic_object_view, based on whether the superclass had an error or not:
  • I could construct the form again, and the formsets again, and basically redo what the superclass did
  • And of course, it would need redoing again one layer up in "mobile_view".
Or have I missed something I can test in the view itself (i.e. self.<something>) or the return HTTPResponse?

Thanks, Shaheed
Reply all
Reply to author
Forward
0 new messages