Opened 90 minutes ago
#37004 assigned Cleanup/optimization
BaseModelFormSet could leverage totally_ordered property
| Reported by: | Jacob Walls | Owned by: | Sarah Boyce |
|---|---|---|---|
| Component: | Forms | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
#36857 added a new property totally_ordered on QuerySet to capture the difference between a queryset having some ordering versus a "stable, deterministic" ordering.
I noticed that we probably want to use that new property here in BaseModelFormSet for the purpose described in #10163:
-
django/forms/models.py
diff --git a/django/forms/models.py b/django/forms/models.py index 104369c0b0..3843203a1d 100644
a b class BaseModelFormSet(BaseFormSet, AltersData): 776 776 # If the queryset isn't already ordered we need to add an 777 777 # artificial ordering here to make sure that all formsets 778 778 # constructed from this queryset have the same form order. 779 if not qs. ordered:779 if not qs.totally_ordered: 780 780 qs = qs.order_by(self.model._meta.pk.name) 781 781 782 782 # Removed queryset limiting here. As per discussion re: #13023
Tentatively assigning to Sarah to see if a good fit for any Djangonauts this session. This would involve cooking up a test.
Note:
See TracTickets
for help on using tickets.