fix slow get_is_sortable when using with inline admins
the first `if` call did execute the whole `select` query with (perhaps) millions of records in them, even though the only result needed here is one record. The acually used queryset later will be filtered by the parent-model.master
parent
5d1a6f5e98
commit
4d8091bc5e
|
|
@ -6,12 +6,14 @@ def check_inheritance(obj):
|
|||
|
||||
|
||||
def get_is_sortable(objects):
|
||||
if objects:
|
||||
if check_inheritance(objects[0]):
|
||||
if objects.count() > 1:
|
||||
return True
|
||||
if objects.count() < 2:
|
||||
return False
|
||||
|
||||
if not check_inheritance(objects[:1][0]):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def is_self_referential(cls):
|
||||
cls_type = type(cls)
|
||||
|
|
|
|||
Loading…
Reference in New Issue