From 43f8b097420d610522eee8e80d48282b0ef1fcf9 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 21 Jul 2014 12:09:53 +0200 Subject: Ordering of formset items martch to the meta ordering if available otherwise ordered by pk (refs #1595) --- ishtar_common/wizards.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'ishtar_common/wizards.py') diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index 368c6e627..190a7fc86 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -750,7 +750,10 @@ class Wizard(NamedUrlWizardView): if not hasattr(obj, key): return initial keys = c_form.form.base_fields.keys() - for child_obj in getattr(obj, key).order_by('pk').all(): + query = getattr(obj, key) + if not obj._meta.ordering: + query = query.order_by('pk') + for child_obj in query.all(): if not keys: break vals = {} -- cgit v1.2.3