Skip to content

Improve transaction handling in generic inline formset views

Sivert Olstad requested to merge improve-inline-formset-trancation-handling into main

This PR is motivated by the error we encountered in !271 (merged) with these views, and my own work with transactions. This PR both simplifies and improves the use of transactions in the generic inline formset views. I've tested that this works with the expanded event views in !271 (merged).

  • form_valid and formset_valid are now called by form_and_formset_valid, This simplifies the code, especially by not requiring us to manually call transaction.rollback when the form is valid but the formset isn't.
  • form_invalid and formset_invalid have been combined into a single form_or_formset_invalid. There was no real reason to have separate functions for this, and now we no longer need to keep track of whether it is the form or the formset that isn't valid.
Edited by Sivert Olstad

Merge request reports