Now order_by() works like queries for referencing deeper fields (replacing . with __). old: order_by('mydoc.myattr') / new: order_by('mydoc__myattr'). Closes #45
This commit is contained in:
		| @@ -670,11 +670,13 @@ class QuerySet(object): | |||||||
|         """ |         """ | ||||||
|         key_list = [] |         key_list = [] | ||||||
|         for key in keys: |         for key in keys: | ||||||
|  |             if not key: continue | ||||||
|             direction = pymongo.ASCENDING |             direction = pymongo.ASCENDING | ||||||
|             if key[0] == '-': |             if key[0] == '-': | ||||||
|                 direction = pymongo.DESCENDING |                 direction = pymongo.DESCENDING | ||||||
|             if key[0] in ('-', '+'): |             if key[0] in ('-', '+'): | ||||||
|                 key = key[1:] |                 key = key[1:] | ||||||
|  |             key = key.replace('__', '.') | ||||||
|             key_list.append((key, direction)) |             key_list.append((key, direction)) | ||||||
|  |  | ||||||
|         self._ordering = key_list |         self._ordering = key_list | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user