diff --git a/django_tablib/admin/__init__.py b/django_tablib/admin/__init__.py index 60b9d51..f9757d4 100644 --- a/django_tablib/admin/__init__.py +++ b/django_tablib/admin/__init__.py @@ -5,7 +5,7 @@ import django from distutils.version import LooseVersion from django.contrib import admin -from django.core.urlresolvers import reverse +from django.urls import reverse from django.http import Http404 @@ -89,6 +89,7 @@ def get_tablib_queryset(self, request): search_fields = (self.get_search_fields(request) if hasattr(self, 'get_search_fields') else self.search_fields) + sortable_by = self.get_sortable_by(request) cl = ChangeList( request, @@ -103,6 +104,7 @@ def get_tablib_queryset(self, request): self.list_max_show_all, self.list_editable, self, + sortable_by ) return cl.get_queryset(request) diff --git a/django_tablib/datasets.py b/django_tablib/datasets.py index c683dee..f48da4d 100644 --- a/django_tablib/datasets.py +++ b/django_tablib/datasets.py @@ -20,7 +20,7 @@ def __init__(self, queryset, headers=None, encoding='utf-8'): # django < 1.9 field_names = v_qs.field_names headers.extend(field_names) - headers.extend(v_qs.query.aggregate_select) + headers.extend(v_qs.query.annotation_select) self.header_list = headers self.attr_list = headers