MCPcopy
hub / github.com/django/django / get_order_dir

Function get_order_dir

django/db/models/sql/query.py:2794–2805  ·  view source on GitHub ↗

Return the field name and direction for an order specification. For example, '-foo' is returned as ('foo', 'DESC'). The 'default' param is used to indicate which way no prefix (or a '+' prefix) should sort. The '-' prefix always sorts the opposite way.

(field, default="ASC")

Source from the content-addressed store, hash-verified

2792
2793
2794def get_order_dir(field, default="ASC"):
2795 """
2796 Return the field name and direction for an order specification. For
2797 example, '-foo' is returned as ('foo', 'DESC').
2798
2799 The 'default' param is used to indicate which way no prefix (or a '+'
2800 prefix) should sort. The '-' prefix always sorts the opposite way.
2801 """
2802 dirn = ORDER_DIR[default]
2803 if field[0] == "-":
2804 return field[1:], dirn[1]
2805 return field, dirn[0]
2806
2807
2808class JoinPromoter:

Callers 2

_order_by_pairsMethod · 0.90
find_ordering_nameMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected