1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Merged isinstance() calls.

This commit is contained in:
Mariusz Felisiak 2017-09-13 21:00:45 +02:00 committed by Tim Graham
parent c6a1faecc3
commit 0214f367bc
4 changed files with 4 additions and 4 deletions

View File

@ -134,7 +134,7 @@ class BaseModelAdmin(metaclass=forms.MediaDefiningClass):
return self.formfield_for_choice_field(db_field, request, **kwargs)
# ForeignKey or ManyToManyFields
if isinstance(db_field, models.ManyToManyField) or isinstance(db_field, models.ForeignKey):
if isinstance(db_field, (models.ForeignKey, models.ManyToManyField)):
# Combine the field kwargs with any options for formfield_overrides.
# Make sure the passed in **kwargs override anything in
# formfield_overrides because **kwargs is more specific, and should

View File

@ -394,7 +394,7 @@ def display_for_field(value, field, empty_value_display):
return dict(field.flatchoices).get(value, empty_value_display)
# NullBooleanField needs special-case null-handling, so it comes
# before the general null test.
elif isinstance(field, models.BooleanField) or isinstance(field, models.NullBooleanField):
elif isinstance(field, (models.BooleanField, models.NullBooleanField)):
return _boolean_icon(value)
elif value is None:
return empty_value_display

View File

@ -83,7 +83,7 @@ class ArrayField(Field):
return '%s[%s]' % (self.base_field.db_type(connection), size)
def get_db_prep_value(self, value, connection, prepared=False):
if isinstance(value, list) or isinstance(value, tuple):
if isinstance(value, (list, tuple)):
return [self.base_field.get_db_prep_value(i, connection, prepared=False) for i in value]
return value

View File

@ -837,7 +837,7 @@ class BaseModelFormSet(BaseFormSet):
pk_value = None
except IndexError:
pk_value = None
if isinstance(pk, OneToOneField) or isinstance(pk, ForeignKey):
if isinstance(pk, (ForeignKey, OneToOneField)):
qs = pk.remote_field.model._default_manager.get_queryset()
else:
qs = self.model._default_manager.get_queryset()