From cf1a2103dda7ce70a0e7d24de06ef54df6ef0910 Mon Sep 17 00:00:00 2001 From: matt-leach Date: Mon, 22 Dec 2014 14:36:15 +0000 Subject: [PATCH 1/3] Updating VERSION comparison to be compatible with all 1.5.x --- adminsortable/admin.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/adminsortable/admin.py b/adminsortable/admin.py index bd7fab3..6610ebf 100644 --- a/adminsortable/admin.py +++ b/adminsortable/admin.py @@ -291,7 +291,7 @@ class SortableInlineBase(SortableAdminBase, InlineModelAdmin): class SortableTabularInline(TabularInline, SortableInlineBase): """Custom template that enables sorting for tabular inlines""" - if VERSION <= (1, 5): + if VERSION < (1, 6): template = 'adminsortable/edit_inline/tabular-1.5.x.html' else: template = 'adminsortable/edit_inline/tabular.html' @@ -299,7 +299,7 @@ class SortableTabularInline(TabularInline, SortableInlineBase): class SortableStackedInline(StackedInline, SortableInlineBase): """Custom template that enables sorting for stacked inlines""" - if VERSION <= (1, 5): + if VERSION < (1, 6): template = 'adminsortable/edit_inline/stacked-1.5.x.html' else: template = 'adminsortable/edit_inline/stacked.html' @@ -307,7 +307,7 @@ class SortableStackedInline(StackedInline, SortableInlineBase): class SortableGenericTabularInline(GenericTabularInline, SortableInlineBase): """Custom template that enables sorting for tabular inlines""" - if VERSION <= (1, 5): + if VERSION < (1, 6): template = 'adminsortable/edit_inline/tabular-1.5.x.html' else: template = 'adminsortable/edit_inline/tabular.html' @@ -315,7 +315,7 @@ class SortableGenericTabularInline(GenericTabularInline, SortableInlineBase): class SortableGenericStackedInline(GenericStackedInline, SortableInlineBase): """Custom template that enables sorting for stacked inlines""" - if VERSION <= (1, 5): + if VERSION < (1, 6): template = 'adminsortable/edit_inline/stacked-1.5.x.html' else: template = 'adminsortable/edit_inline/stacked.html' From c7f2d63ec9d6b3141673f51a01b43d95e8d523ad Mon Sep 17 00:00:00 2001 From: matt-leach Date: Mon, 22 Dec 2014 14:44:02 +0000 Subject: [PATCH 2/3] calling the correct queryset/get_queryset for VERSION --- adminsortable/admin.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/adminsortable/admin.py b/adminsortable/admin.py index 6610ebf..3625cab 100644 --- a/adminsortable/admin.py +++ b/adminsortable/admin.py @@ -278,7 +278,11 @@ class SortableInlineBase(SortableAdminBase, InlineModelAdmin): ' and SortableStackedInline must inherit from Sortable') def get_queryset(self, request): - qs = super(SortableInlineBase, self).get_queryset(request) + if VERSION < (1, 6): + qs = super(SortableInlineBase, self).queryset(request) + else: + qs = super(SortableInlineBase, self).get_queryset(request) + if get_is_sortable(qs): self.model.is_sortable = True else: From e0b38fb705a16856c57e8cd91c79449708083519 Mon Sep 17 00:00:00 2001 From: matt-leach Date: Mon, 22 Dec 2014 14:57:17 +0000 Subject: [PATCH 3/3] Using __class__ to get model class as model is not an attribute of class Meta in Django 1.5.x --- adminsortable/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adminsortable/models.py b/adminsortable/models.py index 2e9d907..d17a815 100644 --- a/adminsortable/models.py +++ b/adminsortable/models.py @@ -80,7 +80,7 @@ class Sortable(models.Model): {self.sortable_foreign_key.name: sfk_obj.id}) try: - obj = self._meta.model.objects.filter(**filters)[:1][0] + obj = self.__class__.objects.filter(**filters)[:1][0] except IndexError: obj = None