mirror of https://github.com/django/django.git
Fixed #28907 -- Removed unnecessary if statements.
This commit is contained in:
parent
c6864a01b2
commit
02d9419fe3
|
@ -104,7 +104,6 @@ class ChangeList:
|
||||||
raise DisallowedModelAdminLookup("Filtering by %s not allowed" % key)
|
raise DisallowedModelAdminLookup("Filtering by %s not allowed" % key)
|
||||||
|
|
||||||
filter_specs = []
|
filter_specs = []
|
||||||
if self.list_filter:
|
|
||||||
for list_filter in self.list_filter:
|
for list_filter in self.list_filter:
|
||||||
if callable(list_filter):
|
if callable(list_filter):
|
||||||
# This is simply a custom list filter class.
|
# This is simply a custom list filter class.
|
||||||
|
@ -116,8 +115,8 @@ class ChangeList:
|
||||||
field, field_list_filter_class = list_filter
|
field, field_list_filter_class = list_filter
|
||||||
else:
|
else:
|
||||||
# This is simply a field name, so use the default
|
# This is simply a field name, so use the default
|
||||||
# FieldListFilter class that has been registered for
|
# FieldListFilter class that has been registered for the
|
||||||
# the type of the given field.
|
# type of the given field.
|
||||||
field, field_list_filter_class = list_filter, FieldListFilter.create
|
field, field_list_filter_class = list_filter, FieldListFilter.create
|
||||||
if not isinstance(field, models.Field):
|
if not isinstance(field, models.Field):
|
||||||
field_path = field
|
field_path = field
|
||||||
|
@ -126,11 +125,11 @@ class ChangeList:
|
||||||
lookup_params_count = len(lookup_params)
|
lookup_params_count = len(lookup_params)
|
||||||
spec = field_list_filter_class(
|
spec = field_list_filter_class(
|
||||||
field, request, lookup_params,
|
field, request, lookup_params,
|
||||||
self.model, self.model_admin, field_path=field_path
|
self.model, self.model_admin, field_path=field_path,
|
||||||
)
|
)
|
||||||
# field_list_filter_class removes any lookup_params it
|
# field_list_filter_class removes any lookup_params it
|
||||||
# processes. If that happened, check if distinct() is
|
# processes. If that happened, check if distinct() is needed to
|
||||||
# needed to remove duplicate results.
|
# remove duplicate results.
|
||||||
if lookup_params_count > len(lookup_params):
|
if lookup_params_count > len(lookup_params):
|
||||||
use_distinct = use_distinct or lookup_needs_distinct(self.lookup_opts, field_path)
|
use_distinct = use_distinct or lookup_needs_distinct(self.lookup_opts, field_path)
|
||||||
if spec and spec.has_output():
|
if spec and spec.has_output():
|
||||||
|
|
|
@ -62,7 +62,6 @@ class ModelIterable(BaseIterable):
|
||||||
related_populators = get_related_populators(klass_info, select, db)
|
related_populators = get_related_populators(klass_info, select, db)
|
||||||
for row in compiler.results_iter(results):
|
for row in compiler.results_iter(results):
|
||||||
obj = model_cls.from_db(db, init_list, row[model_fields_start:model_fields_end])
|
obj = model_cls.from_db(db, init_list, row[model_fields_start:model_fields_end])
|
||||||
if related_populators:
|
|
||||||
for rel_populator in related_populators:
|
for rel_populator in related_populators:
|
||||||
rel_populator.populate(row, obj)
|
rel_populator.populate(row, obj)
|
||||||
if annotation_col_map:
|
if annotation_col_map:
|
||||||
|
@ -1771,7 +1770,6 @@ class RelatedPopulator:
|
||||||
obj = None
|
obj = None
|
||||||
else:
|
else:
|
||||||
obj = self.model_cls.from_db(self.db, self.init_list, obj_data)
|
obj = self.model_cls.from_db(self.db, self.init_list, obj_data)
|
||||||
if self.related_populators:
|
|
||||||
for rel_iter in self.related_populators:
|
for rel_iter in self.related_populators:
|
||||||
rel_iter.populate(row, obj)
|
rel_iter.populate(row, obj)
|
||||||
self.local_setter(from_obj, obj)
|
self.local_setter(from_obj, obj)
|
||||||
|
|
|
@ -1363,7 +1363,6 @@ def url(parser, token):
|
||||||
asvar = bits[-1]
|
asvar = bits[-1]
|
||||||
bits = bits[:-2]
|
bits = bits[:-2]
|
||||||
|
|
||||||
if bits:
|
|
||||||
for bit in bits:
|
for bit in bits:
|
||||||
match = kwarg_re.match(bit)
|
match = kwarg_re.match(bit)
|
||||||
if not match:
|
if not match:
|
||||||
|
|
Loading…
Reference in New Issue