However, keep the logic for falling back to extracting panel definitions
from the model class as snippets-specific. ModelViewSets are likely used
with models that are more low-level and thus we want developers to
explicitly define the fields that are editable in the admin, just like
how Django's ModelForm works.
Until now, if you've set an index_results_template_name or used the
namespaced template-lookup to override it, it was only used for the
ajax-results.
The include is now similar to wagtailadmin/generic/index.html.
This prevents `create_extra_permissions` from querying or creating
ContentType or Permission objects if the models cannot be found.
When using multiple databases which do not have the auth_permission
table `create_extra_permissions` will cause migrate to fail.
This is similar to https://code.djangoproject.com/ticket/24075.
Thanks to @crccheck for additional bug reporting.
The `check` method in BaseSearchQueryCompiler rejects these, so this doesn't make a difference to real-world queries. However, the check is only performed after compilation is complete, so we still need to guard against this with `searchable_fields.get`.
However, our tests _do_ blithely use non-existent fields, so fix those too...
At indexing time, any SearchFields with a boost value assigned are copied to an index field named "_all_text_boost_{value}". Then, when querying, we compile a list of all such index fields and query on those fields, with the relevant boost applied to each one.
Previously, "all such index fields" was obtained by looking at distinct boost values across all indexed models. However, we only really need to consider models that can actually appear in the results - i.e. are subclasses of self.queryset.model. If a boost value does not appear among this set of models, then these models will never contribute anything to that "_all_text_boost_{value}" index field, and so it's pointless to query it.
Otherwise, the list of values will be stringified and then URL encoded, resulting in something like locale=%5B%27en%27%5D
From parse_qs docs: Use the urllib.parse.urlencode() function (with the doseq parameter set to True) to convert such dictionaries into query strings.