Created
August 4, 2017 10:06
-
-
Save dlyapun/67522ce2fa228217b116a001d4033137 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_search_results(self, request, queryset, search_term): | |
queryset, use_distinct = super(OogleUserAdmin, self).get_search_results(request, queryset, search_term) | |
if search_term.isdigit(): | |
queryset = self.model.objects.filter(Q(id=search_term) | Q(dentist__dentist_id=search_term) | Q(login_dentist__dentist_id=search_term)) | |
sort_param = request.GET.get('o', '').split('.') | |
full_sort_param = [] | |
index = 1 | |
for field in self.list_display: | |
for param in sort_param: | |
if str(index) in param: | |
full_sort_param.append(param.replace(str(index), field)) | |
index += 1 | |
queryset = queryset.order_by(*full_sort_param) | |
return queryset, use_distinct |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment