Improve QuerySet order

This commit is contained in:
Phin Wolkwitz
2026-08-05 14:05:31 +02:00
parent 5a0f52d639
commit 88b0274e5c
+3 -2
View File
@@ -33,7 +33,7 @@
# License for the specific language governing permissions and limitations under the License.
from datetime import datetime
from django.db.models import Exists, OuterRef, Q
from django.db.models import Exists, OuterRef, Q, F
from i18nfield.strings import LazyI18nString
from pretix.base.email import get_email_context
@@ -86,7 +86,8 @@ def send_mails_to_orders(event: Event, user: int, subject: dict, message: dict,
list_id__in=checkin_lists or []
)
),
).order_by('pk').prefetch_related('addons', 'subevent'):
).order_by(F("addon_to_id").asc(nulls_first=True)).prefetch_related('addons', 'subevent'):
# ordered QuerySet to make sure we always handle parent order positions before add-ons
is_addon = p.addon_to_id is not None