apis_core.generic.helpers#

Module Contents#

Functions#

default_search_fields

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_search_filter

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.

mro_paths

Create a list of MRO classes for a Django model

template_names_via_mro

Use the MRO to generate a list of template names for a model

permission_fullname

module_paths

makeclassprefix

import_string

first_member_match

split_and_strip_parameter

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”]

string_to_bool

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.mro_paths(model)[source]#

Create a list of MRO classes for a Django model

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.permission_fullname(action: str, model: object) → str[source]#
apis_core.generic.helpers.module_paths(model, path: str = '', suffix: str = '') → tuple[source]#
apis_core.generic.helpers.makeclassprefix(string: str) → str[source]#
apis_core.generic.helpers.import_string(dotted_path)[source]#
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”]

apis_core.generic.helpers.string_to_bool(string: str = 'false') → bool[source]#

Convert a string to a boolean representing its semantic value