mirror of
https://github.com/jazzband/django-admin-sortable.git
synced 2026-05-08 23:34:44 +00:00
Check that the parent model is a SortableMixin before enabling sorting them
This commit is contained in:
parent
3263eb0e34
commit
2bb6a677fe
1 changed files with 3 additions and 1 deletions
|
|
@ -182,7 +182,9 @@ class SortableAdmin(SortableAdminBase, ModelAdmin):
|
||||||
# Django < 1.9
|
# Django < 1.9
|
||||||
sortable_by_fk = field.rel.to
|
sortable_by_fk = field.rel.to
|
||||||
sortable_by_field_name = field.name.lower()
|
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:
|
if sortable_by_property:
|
||||||
# backwards compatibility for < 1.1.1, where sortable_by was a
|
# backwards compatibility for < 1.1.1, where sortable_by was a
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue