Check that the parent model is a SortableMixin before enabling sorting them

master
blag 2020-05-19 18:37:55 -07:00
parent 3263eb0e34
commit 2bb6a677fe
No known key found for this signature in database
GPG Key ID: 30870D32F59C5F40
1 changed files with 3 additions and 1 deletions

View File

@ -182,7 +182,9 @@ class SortableAdmin(SortableAdminBase, ModelAdmin):
# Django < 1.9
sortable_by_fk = field.rel.to
sortable_by_field_name = field.name.lower()
sortable_by_class_is_sortable = sortable_by_fk.objects.count() >= 2
sortable_by_class_is_sortable = \
isinstance(sortable_by_fk, SortableMixin) and \
sortable_by_fk.objects.count() >= 2
if sortable_by_property:
# backwards compatibility for < 1.1.1, where sortable_by was a