Fixed #28930 -- Simplified code with any() and all().

This commit is contained in:
Дилян Палаузов 2017-12-27 00:14:12 +05:30 committed by Tim Graham
parent c21f158295
commit 4c599ece57
18 changed files with 54 additions and 115 deletions

View file

@ -336,10 +336,10 @@ class InlineAdminForm(AdminForm):
return True
# Also search any parents for an auto field. (The pk info is propagated to child
# models so that does not need to be checked in parents.)
for parent in self.form._meta.model._meta.get_parent_list():
if parent._meta.auto_field or not parent._meta.model._meta.pk.editable:
return True
return False
return any(
parent._meta.auto_field or not parent._meta.model._meta.pk.editable
for parent in self.form._meta.model._meta.get_parent_list()
)
def pk_field(self):
return AdminField(self.form, self.formset._pk_field.name, False)