Don't serialize full objects in ConcurrentProtectedModelForm
authorMagnus Hagander <magnus@hagander.net>
Fri, 29 Aug 2025 13:15:16 +0000 (15:15 +0200)
committerMagnus Hagander <magnus@hagander.net>
Fri, 29 Aug 2025 13:17:27 +0000 (15:17 +0200)
commit92960aafd31c08b7248354b74af9c24cc82c8d1d
tree114b1b77a1c4b9c0d729076addaa4083682ddc06
parentb23da5c2a661b1847609d478d3c2c0e2ed3d6068
Don't serialize full objects in ConcurrentProtectedModelForm

The idea behind the form is to serialize the state of the data from the
form before it's rendered and then make sure it hasn't changed before
it's submitted, since that would overwrite concurrent changes. The
problem with the implementation is it serialized the entire objects on
the other side of a foreign key or manytomany relationship, which could
be very large if it was for example Speaker records with photos. (One
example found made a simple form over 2.5Mb due to this, which triggered
the oversize form limits)

Update this to instead just serialize the primary key of the object. The
way forms work that *should* always exist at this point otherwise it
cannot be added. And this makes the form a *lot* smaller and faster.

Per bug report from Karen Jex
postgresqleu/util/forms.py