Avoid double-patching querysets in LocalSiteAwareModelFormMixin.
Review Request #10482 — Created March 31, 2019 and submitted — Latest diff uploaded
The mixin for ensuring Local Site restrictions for forms was
double-patching querysets when limiting to a Local Site. The first patch
would happen at form construction time, and the second would happen at
form cleaning time (though this one was temporary). This caused queries
SELECT ... WHERE local_site_id=1 AND local_site_id=1.
This change fixes that to only patch during form cleaning if it hasn't
already patched at form construction.
It also updates the field accesses to work with newer versions of
Django, and splits a unit test for these restrictions into two to avoid
an ordering difference on the newer versions.
Unit tests pass on Django 1.6 and 1.11 (with other in-progress changes).