commit
e83e31cb22
|
|
@ -278,7 +278,11 @@ class SortableInlineBase(SortableAdminBase, InlineModelAdmin):
|
||||||
' and SortableStackedInline must inherit from Sortable')
|
' and SortableStackedInline must inherit from Sortable')
|
||||||
|
|
||||||
def get_queryset(self, request):
|
def get_queryset(self, request):
|
||||||
|
if VERSION < (1, 6):
|
||||||
|
qs = super(SortableInlineBase, self).queryset(request)
|
||||||
|
else:
|
||||||
qs = super(SortableInlineBase, self).get_queryset(request)
|
qs = super(SortableInlineBase, self).get_queryset(request)
|
||||||
|
|
||||||
if get_is_sortable(qs):
|
if get_is_sortable(qs):
|
||||||
self.model.is_sortable = True
|
self.model.is_sortable = True
|
||||||
else:
|
else:
|
||||||
|
|
@ -291,7 +295,7 @@ class SortableInlineBase(SortableAdminBase, InlineModelAdmin):
|
||||||
|
|
||||||
class SortableTabularInline(TabularInline, SortableInlineBase):
|
class SortableTabularInline(TabularInline, SortableInlineBase):
|
||||||
"""Custom template that enables sorting for tabular inlines"""
|
"""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'
|
template = 'adminsortable/edit_inline/tabular-1.5.x.html'
|
||||||
else:
|
else:
|
||||||
template = 'adminsortable/edit_inline/tabular.html'
|
template = 'adminsortable/edit_inline/tabular.html'
|
||||||
|
|
@ -299,7 +303,7 @@ class SortableTabularInline(TabularInline, SortableInlineBase):
|
||||||
|
|
||||||
class SortableStackedInline(StackedInline, SortableInlineBase):
|
class SortableStackedInline(StackedInline, SortableInlineBase):
|
||||||
"""Custom template that enables sorting for stacked inlines"""
|
"""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'
|
template = 'adminsortable/edit_inline/stacked-1.5.x.html'
|
||||||
else:
|
else:
|
||||||
template = 'adminsortable/edit_inline/stacked.html'
|
template = 'adminsortable/edit_inline/stacked.html'
|
||||||
|
|
@ -307,7 +311,7 @@ class SortableStackedInline(StackedInline, SortableInlineBase):
|
||||||
|
|
||||||
class SortableGenericTabularInline(GenericTabularInline, SortableInlineBase):
|
class SortableGenericTabularInline(GenericTabularInline, SortableInlineBase):
|
||||||
"""Custom template that enables sorting for tabular inlines"""
|
"""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'
|
template = 'adminsortable/edit_inline/tabular-1.5.x.html'
|
||||||
else:
|
else:
|
||||||
template = 'adminsortable/edit_inline/tabular.html'
|
template = 'adminsortable/edit_inline/tabular.html'
|
||||||
|
|
@ -315,7 +319,7 @@ class SortableGenericTabularInline(GenericTabularInline, SortableInlineBase):
|
||||||
|
|
||||||
class SortableGenericStackedInline(GenericStackedInline, SortableInlineBase):
|
class SortableGenericStackedInline(GenericStackedInline, SortableInlineBase):
|
||||||
"""Custom template that enables sorting for stacked inlines"""
|
"""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'
|
template = 'adminsortable/edit_inline/stacked-1.5.x.html'
|
||||||
else:
|
else:
|
||||||
template = 'adminsortable/edit_inline/stacked.html'
|
template = 'adminsortable/edit_inline/stacked.html'
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ class Sortable(models.Model):
|
||||||
{self.sortable_foreign_key.name: sfk_obj.id})
|
{self.sortable_foreign_key.name: sfk_obj.id})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
obj = self._meta.model.objects.filter(**filters)[:1][0]
|
obj = self.__class__.objects.filter(**filters)[:1][0]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
obj = None
|
obj = None
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue