def get_ordered_results(cls, qs: Select, order_by: str, order_direction: str) -> Select: if order_by and order_direction and hasattr(cls.model_class.c, order_by): field = getattr(cls.model_class.c, order_by) if order_direction == "desc": qs = qs.order_by(field.desc()) else: qs = qs.order_by(field) return qs
def get_default_ordering(cls, qs: Select) -> Select: return qs.order_by("id")