diff --git a/app/utils.py b/app/utils.py index a5c2e06e183a3dd9407939fdc3652f4cea7b9589..a8f7896e84893626ff5a99ff18ffadfcabdd74a4 100644 --- a/app/utils.py +++ b/app/utils.py @@ -140,7 +140,8 @@ def get_model_choices(model, allow_none=False, attr='name', query=None): if allow_none: choices = [(None, '')] if query is None: - query = model.query.order_by(getattr(model, attr)) + query = model.query + query = query.order_by(getattr(model, attr)) choices.extend([(str(instance.id), getattr(instance, attr)) for instance in query.all()]) return choices