refactor: tweak the horrible code in SearchableField (#3957)

* Fix: Tweak the horrible code in SearchableField so another corner case works

Fixes #3940. Hopefully doesn't break anything.

* fix: remove incorrect remaining loop.

Co-authored-by: Robert Sparks <rjsparks@nostrum.com>
This commit is contained in:
Lars Eggert 2022-05-19 10:38:10 -07:00 committed by GitHub
parent 8ef92312d0
commit fa17ddd705
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -264,10 +264,7 @@ class SearchableField(forms.MultipleChoiceField):
value = value[0]
else:
if not isinstance(value[0], self.model):
qs = self.get_model_instances(value[0])
for val in value[1:]:
qs = qs.union(self.get_model_instances(val))
value = qs
value = self.get_model_instances(value)
if isinstance(value, int):
value = str(value)
if isinstance(value, str):
@ -343,4 +340,4 @@ class MissingOkImageField(models.ImageField):
try:
super().update_dimension_fields(*args, **kwargs)
except FileNotFoundError:
pass # don't do anything if the file has gone missing
pass # don't do anything if the file has gone missing