apis_core.generic.helpers#
Module Contents#
Functions#
Retrieve the default model fields to use for a search operation By default those are all the CharFields and TextFields of a model. It is also possible to define those fields on the model using the _default_search_fields attribute. The method also takes a field_names argument to override the list of fields. |
|
Generate a default search filter that searches for the query This helper can be used by autocomplete querysets if nothing fancier is needed. If the prefix is set, the field names will be prefixed with that string - this can be useful if you want to use the generate_search_filter in a Q combined query while searching over multiple models. |
|
Create a list of MRO classes for a Django model |
|
Use the MRO to generate a list of template names for a model |
|
Clean a URI param list type This method iterates through a list of strings. It looks if the items contain a comma separated list of items and then splits those and also runs strip on all those items. So out of [“foo.bar”, “bar.faz, faz.foo”] it creates a list [“foo.bar”, “bar.faz”, “faz.foo”] |
|
Convert a string to a boolean representing its semantic value |
Data#
API#
- apis_core.generic.helpers.logger = 'getLogger(...)'#
- apis_core.generic.helpers.default_search_fields(model, field_names=None)[source]#
Retrieve the default model fields to use for a search operation By default those are all the CharFields and TextFields of a model. It is also possible to define those fields on the model using the _default_search_fields attribute. The method also takes a field_names argument to override the list of fields.
- apis_core.generic.helpers.generate_search_filter(model, query, fields_to_search=None, prefix='')[source]#
Generate a default search filter that searches for the query This helper can be used by autocomplete querysets if nothing fancier is needed. If the prefix is set, the field names will be prefixed with that string - this can be useful if you want to use the generate_search_filter in a Q combined query while searching over multiple models.
- apis_core.generic.helpers.template_names_via_mro(model, folder='', prefix='', suffix='')[source]#
Use the MRO to generate a list of template names for a model
- apis_core.generic.helpers.first_member_match(dotted_path_list: tuple[str], fallback=None) object[source]#
- apis_core.generic.helpers.split_and_strip_parameter(params: list[str]) list[str][source]#
Clean a URI param list type This method iterates through a list of strings. It looks if the items contain a comma separated list of items and then splits those and also runs strip on all those items. So out of [“foo.bar”, “bar.faz, faz.foo”] it creates a list [“foo.bar”, “bar.faz”, “faz.foo”]