We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Syntax highlighting of search input
### Describe the issue

1. Go to a screenshot
2. Enter "not found" as the search term
3. A lot of strings appear as search results, most of them not containing anything related to "not found"


If I enter "not" or "found" then fewer results are found compared to "not found".

### I already tried

- [X] I've read and searched [the documentation](https://docs.weblate.org/).
- [X] I've searched for similar issues in this repository.

### Steps to reproduce the behavior

1. Go to a screenshot
2. Enter "not found" as the search term
3. A lot of strings appear as search results, most of them not containing anything related to "not found"

### Expected behavior

Search only lists strings containing "not found"

### Screenshots

![image](https://github.com/WeblateOrg/weblate/assets/69897582/5dcbab51-0de7-4fd8-b454-eb44a08d528e)


### Exception traceback

_No response_

### How do you run Weblate?

weblate.org service

### Weblate versions

_No response_

### Weblate deploy checks

_No response_

### Additional context

_No response_

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `weblate/utils/forms.py`
Content:
```
1 # Copyright © Michal Čihař <michal@weblate.org>
2 #
3 # SPDX-License-Identifier: GPL-3.0-or-later
4 
5 from crispy_forms.layout import Div, Field
6 from crispy_forms.utils import TEMPLATE_PACK
7 from django import forms
8 from django.core.exceptions import ValidationError
9 from django.db.models import Q
10 from django.forms.models import ModelChoiceIterator
11 from django.template.loader import render_to_string
12 from django.utils.translation import gettext, gettext_lazy
13 
14 from weblate.trans.defines import EMAIL_LENGTH, USERNAME_LENGTH
15 from weblate.trans.filter import FILTERS
16 from weblate.trans.util import sort_unicode
17 from weblate.utils.errors import report_error
18 from weblate.utils.search import parse_query
19 from weblate.utils.validators import validate_email, validate_username
20 
21 
22 class QueryField(forms.CharField):
23     def __init__(self, parser: str = "unit", **kwargs):
24         if "label" not in kwargs:
25             kwargs["label"] = gettext_lazy("Query")
26         if "required" not in kwargs:
27             kwargs["required"] = False
28         self.parser = parser
29         super().__init__(**kwargs)
30 
31     def clean(self, value):
32         if not value:
33             if self.required:
34                 raise ValidationError(gettext("Missing query string."))
35             return ""
36         try:
37             parse_query(value, parser=self.parser)
38         except ValueError as error:
39             raise ValidationError(
40                 gettext("Could not parse query string: {}").format(error)
41             ) from error
42         except Exception as error:
43             report_error(cause="Error parsing search query")
44             raise ValidationError(
45                 gettext("Could not parse query string: {}").format(error)
46             ) from error
47         return value
48 
49 
50 class UsernameField(forms.CharField):
51     default_validators = [validate_username]
52 
53     def __init__(self, *args, **kwargs):
54         params = {
55             "max_length": USERNAME_LENGTH,
56             "help_text": gettext_lazy(
57                 "Username may only contain letters, "
58                 "numbers or the following characters: @ . + - _"
59             ),
60             "label": gettext_lazy("Username"),
61             "required": True,
62         }
63         params.update(kwargs)
64         self.valid = None
65 
66         super().__init__(*args, **params)
67 
68 
69 class UserField(forms.CharField):
70     def __init__(
71         self,
72         queryset=None,
73         empty_label="---------",
74         to_field_name=None,
75         limit_choices_to=None,
76         blank=None,
77         **kwargs,
78     ):
79         # This swallows some parameters to mimic ModelChoiceField API
80         super().__init__(**kwargs)
81 
82     def widget_attrs(self, widget):
83         attrs = super().widget_attrs(widget)
84         attrs["dir"] = "ltr"
85         attrs["class"] = "user-autocomplete"
86         attrs["spellcheck"] = "false"
87         attrs["autocorrect"] = "off"
88         attrs["autocomplete"] = "off"
89         attrs["autocapitalize"] = "off"
90         return attrs
91 
92     def clean(self, value):
93         from weblate.auth.models import User
94 
95         if not value:
96             if self.required:
97                 raise ValidationError(gettext("Missing username or e-mail."))
98             return None
99         try:
100             return User.objects.get(Q(username=value) | Q(email=value))
101         except User.DoesNotExist:
102             raise ValidationError(gettext("Could not find any such user."))
103         except User.MultipleObjectsReturned:
104             raise ValidationError(gettext("More possible users were found."))
105 
106 
107 class EmailField(forms.EmailField):
108     """
109     Slightly restricted EmailField.
110 
111     We blacklist some additional local parts and customize error messages.
112     """
113 
114     default_validators = [validate_email]
115 
116     def __init__(self, *args, **kwargs):
117         kwargs.setdefault("max_length", EMAIL_LENGTH)
118         super().__init__(*args, **kwargs)
119 
120 
121 class SortedSelectMixin:
122     """Mixin for Select widgets to sort choices alphabetically."""
123 
124     def optgroups(self, name, value, attrs=None):
125         groups = super().optgroups(name, value, attrs)
126         return sort_unicode(groups, lambda val: str(val[1][0]["label"]))
127 
128 
129 class ColorWidget(forms.RadioSelect):
130     def __init__(self, attrs=None, choices=()):
131         attrs = {**(attrs or {}), "class": "color_edit"}
132         super().__init__(attrs, choices)
133 
134 
135 class SortedSelectMultiple(SortedSelectMixin, forms.SelectMultiple):
136     """Wrapper class to sort choices alphabetically."""
137 
138 
139 class SortedSelect(SortedSelectMixin, forms.Select):
140     """Wrapper class to sort choices alphabetically."""
141 
142 
143 class ContextDiv(Div):
144     def __init__(self, *fields, **kwargs):
145         self.context = kwargs.pop("context", {})
146         super().__init__(*fields, **kwargs)
147 
148     def render(self, form, context, template_pack=TEMPLATE_PACK, **kwargs):
149         template = self.get_template_name(template_pack)
150         return render_to_string(template, self.context)
151 
152 
153 class SearchField(Field):
154     def __init__(self, *args, **kwargs):
155         kwargs["template"] = "snippets/query-field.html"
156         super().__init__(*args, **kwargs)
157 
158     def render(self, form, context, template_pack=TEMPLATE_PACK, **kwargs):
159         extra_context = {"custom_filter_list": self.get_search_query_choices()}
160         return super().render(form, context, template_pack, extra_context, **kwargs)
161 
162     def get_search_query_choices(self):
163         """Return all filtering choices for query field."""
164         filter_keys = [
165             "nottranslated",
166             "todo",
167             "translated",
168             "fuzzy",
169             "suggestions",
170             "variants",
171             "screenshots",
172             "labels",
173             "context",
174             "nosuggestions",
175             "comments",
176             "allchecks",
177             "approved",
178             "unapproved",
179         ]
180         return [
181             (key, FILTERS.get_filter_name(key), FILTERS.get_filter_query(key))
182             for key in filter_keys
183         ]
184 
185 
186 class CachedQueryIterator(ModelChoiceIterator):
187     """
188     Choice iterator for cached querysets.
189 
190     It assumes the queryset is reused and avoids using an iterator or counting queries.
191     """
192 
193     def __iter__(self):
194         if self.field.empty_label is not None:
195             yield ("", self.field.empty_label)
196         for obj in self.queryset:
197             yield self.choice(obj)
198 
199     def __len__(self):
200         return len(self.queryset) + (1 if self.field.empty_label is not None else 0)
201 
202     def __bool__(self):
203         return self.field.empty_label is not None or bool(self.queryset)
204 
205 
206 class NonCopyingSetQuerysetMixin:
207     iterator = CachedQueryIterator
208 
209     def _get_queryset(self):
210         return self._queryset
211 
212     def _set_queryset(self, queryset):
213         self._queryset = queryset
214         self.widget.choices = self.choices
215 
216     queryset = property(_get_queryset, _set_queryset)
217 
218 
219 class CachedModelChoiceField(NonCopyingSetQuerysetMixin, forms.ModelChoiceField):
220     pass
221 
222 
223 class CachedModelMultipleChoiceField(
224     NonCopyingSetQuerysetMixin, forms.ModelMultipleChoiceField
225 ):
226     pass
227
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/weblate/utils/forms.py b/weblate/utils/forms.py
--- a/weblate/utils/forms.py
+++ b/weblate/utils/forms.py
@@ -25,6 +25,8 @@
             kwargs["label"] = gettext_lazy("Query")
         if "required" not in kwargs:
             kwargs["required"] = False
+        if "widget" not in kwargs:
+            kwargs["widget"] = forms.Textarea(attrs={"cols": None, "rows": 1})
         self.parser = parser
         super().__init__(**kwargs)

{"golden_diff": "diff --git a/weblate/utils/forms.py b/weblate/utils/forms.py\n--- a/weblate/utils/forms.py\n+++ b/weblate/utils/forms.py\n@@ -25,6 +25,8 @@\n             kwargs[\"label\"] = gettext_lazy(\"Query\")\n         if \"required\" not in kwargs:\n             kwargs[\"required\"] = False\n+        if \"widget\" not in kwargs:\n+            kwargs[\"widget\"] = forms.Textarea(attrs={\"cols\": None, \"rows\": 1})\n         self.parser = parser\n         super().__init__(**kwargs)\n", "issue": "Syntax highlighting of search input\n### Describe the issue\n\n1. Go to a screenshot\r\n2. Enter \"not found\" as the search term\r\n3. A lot of strings appear as search results, most of them not containing anything related to \"not found\"\r\n\r\n\r\nIf I enter \"not\" or \"found\" then fewer results are found compared to \"not found\".\n\n### I already tried\n\n- [X] I've read and searched [the documentation](https://docs.weblate.org/).\n- [X] I've searched for similar issues in this repository.\n\n### Steps to reproduce the behavior\n\n1. Go to a screenshot\r\n2. Enter \"not found\" as the search term\r\n3. A lot of strings appear as search results, most of them not containing anything related to \"not found\"\n\n### Expected behavior\n\nSearch only lists strings containing \"not found\"\n\n### Screenshots\n\n![image](https://github.com/WeblateOrg/weblate/assets/69897582/5dcbab51-0de7-4fd8-b454-eb44a08d528e)\r\n\n\n### Exception traceback\n\n_No response_\n\n### How do you run Weblate?\n\nweblate.org service\n\n### Weblate versions\n\n_No response_\n\n### Weblate deploy checks\n\n_No response_\n\n### Additional context\n\n_No response_\n", "before_files": [{"content": "# Copyright \u00a9 Michal \u010ciha\u0159 <michal@weblate.org>\n#\n# SPDX-License-Identifier: GPL-3.0-or-later\n\nfrom crispy_forms.layout import Div, Field\nfrom crispy_forms.utils import TEMPLATE_PACK\nfrom django import forms\nfrom django.core.exceptions import ValidationError\nfrom django.db.models import Q\nfrom django.forms.models import ModelChoiceIterator\nfrom django.template.loader import render_to_string\nfrom django.utils.translation import gettext, gettext_lazy\n\nfrom weblate.trans.defines import EMAIL_LENGTH, USERNAME_LENGTH\nfrom weblate.trans.filter import FILTERS\nfrom weblate.trans.util import sort_unicode\nfrom weblate.utils.errors import report_error\nfrom weblate.utils.search import parse_query\nfrom weblate.utils.validators import validate_email, validate_username\n\n\nclass QueryField(forms.CharField):\n    def __init__(self, parser: str = \"unit\", **kwargs):\n        if \"label\" not in kwargs:\n            kwargs[\"label\"] = gettext_lazy(\"Query\")\n        if \"required\" not in kwargs:\n            kwargs[\"required\"] = False\n        self.parser = parser\n        super().__init__(**kwargs)\n\n    def clean(self, value):\n        if not value:\n            if self.required:\n                raise ValidationError(gettext(\"Missing query string.\"))\n            return \"\"\n        try:\n            parse_query(value, parser=self.parser)\n        except ValueError as error:\n            raise ValidationError(\n                gettext(\"Could not parse query string: {}\").format(error)\n            ) from error\n        except Exception as error:\n            report_error(cause=\"Error parsing search query\")\n            raise ValidationError(\n                gettext(\"Could not parse query string: {}\").format(error)\n            ) from error\n        return value\n\n\nclass UsernameField(forms.CharField):\n    default_validators = [validate_username]\n\n    def __init__(self, *args, **kwargs):\n        params = {\n            \"max_length\": USERNAME_LENGTH,\n            \"help_text\": gettext_lazy(\n                \"Username may only contain letters, \"\n                \"numbers or the following characters: @ . + - _\"\n            ),\n            \"label\": gettext_lazy(\"Username\"),\n            \"required\": True,\n        }\n        params.update(kwargs)\n        self.valid = None\n\n        super().__init__(*args, **params)\n\n\nclass UserField(forms.CharField):\n    def __init__(\n        self,\n        queryset=None,\n        empty_label=\"---------\",\n        to_field_name=None,\n        limit_choices_to=None,\n        blank=None,\n        **kwargs,\n    ):\n        # This swallows some parameters to mimic ModelChoiceField API\n        super().__init__(**kwargs)\n\n    def widget_attrs(self, widget):\n        attrs = super().widget_attrs(widget)\n        attrs[\"dir\"] = \"ltr\"\n        attrs[\"class\"] = \"user-autocomplete\"\n        attrs[\"spellcheck\"] = \"false\"\n        attrs[\"autocorrect\"] = \"off\"\n        attrs[\"autocomplete\"] = \"off\"\n        attrs[\"autocapitalize\"] = \"off\"\n        return attrs\n\n    def clean(self, value):\n        from weblate.auth.models import User\n\n        if not value:\n            if self.required:\n                raise ValidationError(gettext(\"Missing username or e-mail.\"))\n            return None\n        try:\n            return User.objects.get(Q(username=value) | Q(email=value))\n        except User.DoesNotExist:\n            raise ValidationError(gettext(\"Could not find any such user.\"))\n        except User.MultipleObjectsReturned:\n            raise ValidationError(gettext(\"More possible users were found.\"))\n\n\nclass EmailField(forms.EmailField):\n    \"\"\"\n    Slightly restricted EmailField.\n\n    We blacklist some additional local parts and customize error messages.\n    \"\"\"\n\n    default_validators = [validate_email]\n\n    def __init__(self, *args, **kwargs):\n        kwargs.setdefault(\"max_length\", EMAIL_LENGTH)\n        super().__init__(*args, **kwargs)\n\n\nclass SortedSelectMixin:\n    \"\"\"Mixin for Select widgets to sort choices alphabetically.\"\"\"\n\n    def optgroups(self, name, value, attrs=None):\n        groups = super().optgroups(name, value, attrs)\n        return sort_unicode(groups, lambda val: str(val[1][0][\"label\"]))\n\n\nclass ColorWidget(forms.RadioSelect):\n    def __init__(self, attrs=None, choices=()):\n        attrs = {**(attrs or {}), \"class\": \"color_edit\"}\n        super().__init__(attrs, choices)\n\n\nclass SortedSelectMultiple(SortedSelectMixin, forms.SelectMultiple):\n    \"\"\"Wrapper class to sort choices alphabetically.\"\"\"\n\n\nclass SortedSelect(SortedSelectMixin, forms.Select):\n    \"\"\"Wrapper class to sort choices alphabetically.\"\"\"\n\n\nclass ContextDiv(Div):\n    def __init__(self, *fields, **kwargs):\n        self.context = kwargs.pop(\"context\", {})\n        super().__init__(*fields, **kwargs)\n\n    def render(self, form, context, template_pack=TEMPLATE_PACK, **kwargs):\n        template = self.get_template_name(template_pack)\n        return render_to_string(template, self.context)\n\n\nclass SearchField(Field):\n    def __init__(self, *args, **kwargs):\n        kwargs[\"template\"] = \"snippets/query-field.html\"\n        super().__init__(*args, **kwargs)\n\n    def render(self, form, context, template_pack=TEMPLATE_PACK, **kwargs):\n        extra_context = {\"custom_filter_list\": self.get_search_query_choices()}\n        return super().render(form, context, template_pack, extra_context, **kwargs)\n\n    def get_search_query_choices(self):\n        \"\"\"Return all filtering choices for query field.\"\"\"\n        filter_keys = [\n            \"nottranslated\",\n            \"todo\",\n            \"translated\",\n            \"fuzzy\",\n            \"suggestions\",\n            \"variants\",\n            \"screenshots\",\n            \"labels\",\n            \"context\",\n            \"nosuggestions\",\n            \"comments\",\n            \"allchecks\",\n            \"approved\",\n            \"unapproved\",\n        ]\n        return [\n            (key, FILTERS.get_filter_name(key), FILTERS.get_filter_query(key))\n            for key in filter_keys\n        ]\n\n\nclass CachedQueryIterator(ModelChoiceIterator):\n    \"\"\"\n    Choice iterator for cached querysets.\n\n    It assumes the queryset is reused and avoids using an iterator or counting queries.\n    \"\"\"\n\n    def __iter__(self):\n        if self.field.empty_label is not None:\n            yield (\"\", self.field.empty_label)\n        for obj in self.queryset:\n            yield self.choice(obj)\n\n    def __len__(self):\n        return len(self.queryset) + (1 if self.field.empty_label is not None else 0)\n\n    def __bool__(self):\n        return self.field.empty_label is not None or bool(self.queryset)\n\n\nclass NonCopyingSetQuerysetMixin:\n    iterator = CachedQueryIterator\n\n    def _get_queryset(self):\n        return self._queryset\n\n    def _set_queryset(self, queryset):\n        self._queryset = queryset\n        self.widget.choices = self.choices\n\n    queryset = property(_get_queryset, _set_queryset)\n\n\nclass CachedModelChoiceField(NonCopyingSetQuerysetMixin, forms.ModelChoiceField):\n    pass\n\n\nclass CachedModelMultipleChoiceField(\n    NonCopyingSetQuerysetMixin, forms.ModelMultipleChoiceField\n):\n    pass\n", "path": "weblate/utils/forms.py"}], "after_files": [{"content": "# Copyright \u00a9 Michal \u010ciha\u0159 <michal@weblate.org>\n#\n# SPDX-License-Identifier: GPL-3.0-or-later\n\nfrom crispy_forms.layout import Div, Field\nfrom crispy_forms.utils import TEMPLATE_PACK\nfrom django import forms\nfrom django.core.exceptions import ValidationError\nfrom django.db.models import Q\nfrom django.forms.models import ModelChoiceIterator\nfrom django.template.loader import render_to_string\nfrom django.utils.translation import gettext, gettext_lazy\n\nfrom weblate.trans.defines import EMAIL_LENGTH, USERNAME_LENGTH\nfrom weblate.trans.filter import FILTERS\nfrom weblate.trans.util import sort_unicode\nfrom weblate.utils.errors import report_error\nfrom weblate.utils.search import parse_query\nfrom weblate.utils.validators import validate_email, validate_username\n\n\nclass QueryField(forms.CharField):\n    def __init__(self, parser: str = \"unit\", **kwargs):\n        if \"label\" not in kwargs:\n            kwargs[\"label\"] = gettext_lazy(\"Query\")\n        if \"required\" not in kwargs:\n            kwargs[\"required\"] = False\n        if \"widget\" not in kwargs:\n            kwargs[\"widget\"] = forms.Textarea(attrs={\"cols\": None, \"rows\": 1})\n        self.parser = parser\n        super().__init__(**kwargs)\n\n    def clean(self, value):\n        if not value:\n            if self.required:\n                raise ValidationError(gettext(\"Missing query string.\"))\n            return \"\"\n        try:\n            parse_query(value, parser=self.parser)\n        except ValueError as error:\n            raise ValidationError(\n                gettext(\"Could not parse query string: {}\").format(error)\n            ) from error\n        except Exception as error:\n            report_error(cause=\"Error parsing search query\")\n            raise ValidationError(\n                gettext(\"Could not parse query string: {}\").format(error)\n            ) from error\n        return value\n\n\nclass UsernameField(forms.CharField):\n    default_validators = [validate_username]\n\n    def __init__(self, *args, **kwargs):\n        params = {\n            \"max_length\": USERNAME_LENGTH,\n            \"help_text\": gettext_lazy(\n                \"Username may only contain letters, \"\n                \"numbers or the following characters: @ . + - _\"\n            ),\n            \"label\": gettext_lazy(\"Username\"),\n            \"required\": True,\n        }\n        params.update(kwargs)\n        self.valid = None\n\n        super().__init__(*args, **params)\n\n\nclass UserField(forms.CharField):\n    def __init__(\n        self,\n        queryset=None,\n        empty_label=\"---------\",\n        to_field_name=None,\n        limit_choices_to=None,\n        blank=None,\n        **kwargs,\n    ):\n        # This swallows some parameters to mimic ModelChoiceField API\n        super().__init__(**kwargs)\n\n    def widget_attrs(self, widget):\n        attrs = super().widget_attrs(widget)\n        attrs[\"dir\"] = \"ltr\"\n        attrs[\"class\"] = \"user-autocomplete\"\n        attrs[\"spellcheck\"] = \"false\"\n        attrs[\"autocorrect\"] = \"off\"\n        attrs[\"autocomplete\"] = \"off\"\n        attrs[\"autocapitalize\"] = \"off\"\n        return attrs\n\n    def clean(self, value):\n        from weblate.auth.models import User\n\n        if not value:\n            if self.required:\n                raise ValidationError(gettext(\"Missing username or e-mail.\"))\n            return None\n        try:\n            return User.objects.get(Q(username=value) | Q(email=value))\n        except User.DoesNotExist:\n            raise ValidationError(gettext(\"Could not find any such user.\"))\n        except User.MultipleObjectsReturned:\n            raise ValidationError(gettext(\"More possible users were found.\"))\n\n\nclass EmailField(forms.EmailField):\n    \"\"\"\n    Slightly restricted EmailField.\n\n    We blacklist some additional local parts and customize error messages.\n    \"\"\"\n\n    default_validators = [validate_email]\n\n    def __init__(self, *args, **kwargs):\n        kwargs.setdefault(\"max_length\", EMAIL_LENGTH)\n        super().__init__(*args, **kwargs)\n\n\nclass SortedSelectMixin:\n    \"\"\"Mixin for Select widgets to sort choices alphabetically.\"\"\"\n\n    def optgroups(self, name, value, attrs=None):\n        groups = super().optgroups(name, value, attrs)\n        return sort_unicode(groups, lambda val: str(val[1][0][\"label\"]))\n\n\nclass ColorWidget(forms.RadioSelect):\n    def __init__(self, attrs=None, choices=()):\n        attrs = {**(attrs or {}), \"class\": \"color_edit\"}\n        super().__init__(attrs, choices)\n\n\nclass SortedSelectMultiple(SortedSelectMixin, forms.SelectMultiple):\n    \"\"\"Wrapper class to sort choices alphabetically.\"\"\"\n\n\nclass SortedSelect(SortedSelectMixin, forms.Select):\n    \"\"\"Wrapper class to sort choices alphabetically.\"\"\"\n\n\nclass ContextDiv(Div):\n    def __init__(self, *fields, **kwargs):\n        self.context = kwargs.pop(\"context\", {})\n        super().__init__(*fields, **kwargs)\n\n    def render(self, form, context, template_pack=TEMPLATE_PACK, **kwargs):\n        template = self.get_template_name(template_pack)\n        return render_to_string(template, self.context)\n\n\nclass SearchField(Field):\n    def __init__(self, *args, **kwargs):\n        kwargs[\"template\"] = \"snippets/query-field.html\"\n        super().__init__(*args, **kwargs)\n\n    def render(self, form, context, template_pack=TEMPLATE_PACK, **kwargs):\n        extra_context = {\"custom_filter_list\": self.get_search_query_choices()}\n        return super().render(form, context, template_pack, extra_context, **kwargs)\n\n    def get_search_query_choices(self):\n        \"\"\"Return all filtering choices for query field.\"\"\"\n        filter_keys = [\n            \"nottranslated\",\n            \"todo\",\n            \"translated\",\n            \"fuzzy\",\n            \"suggestions\",\n            \"variants\",\n            \"screenshots\",\n            \"labels\",\n            \"context\",\n            \"nosuggestions\",\n            \"comments\",\n            \"allchecks\",\n            \"approved\",\n            \"unapproved\",\n        ]\n        return [\n            (key, FILTERS.get_filter_name(key), FILTERS.get_filter_query(key))\n            for key in filter_keys\n        ]\n\n\nclass CachedQueryIterator(ModelChoiceIterator):\n    \"\"\"\n    Choice iterator for cached querysets.\n\n    It assumes the queryset is reused and avoids using an iterator or counting queries.\n    \"\"\"\n\n    def __iter__(self):\n        if self.field.empty_label is not None:\n            yield (\"\", self.field.empty_label)\n        for obj in self.queryset:\n            yield self.choice(obj)\n\n    def __len__(self):\n        return len(self.queryset) + (1 if self.field.empty_label is not None else 0)\n\n    def __bool__(self):\n        return self.field.empty_label is not None or bool(self.queryset)\n\n\nclass NonCopyingSetQuerysetMixin:\n    iterator = CachedQueryIterator\n\n    def _get_queryset(self):\n        return self._queryset\n\n    def _set_queryset(self, queryset):\n        self._queryset = queryset\n        self.widget.choices = self.choices\n\n    queryset = property(_get_queryset, _set_queryset)\n\n\nclass CachedModelChoiceField(NonCopyingSetQuerysetMixin, forms.ModelChoiceField):\n    pass\n\n\nclass CachedModelMultipleChoiceField(\n    NonCopyingSetQuerysetMixin, forms.ModelMultipleChoiceField\n):\n    pass\n", "path": "weblate/utils/forms.py"}]}