apis_core.utils.helpers#
Module Contents#
Functions#
This method is loosely based on the dumpdata admin command. It iterates throug the relevant app models and exports them using a serializer and natural foreign keys. Data exported this way can be reimported into a newly created Django APIS app |
|
Create an colorized html represenation of the difference of two values a and b If show_a is True, colorize deletions in a If show_b is True, colorize insertions in b The value of shorten defines if long parts of strings that contains no change should be shortened |
|
Helper method to parse input values and construct field lookups (https://docs.djangoproject.com/en/4.2/ref/models/querysets/#field-lookups) Parses user input for wildcards and returns a tuple containing the interpreted django lookup string and the trimmed value E.g. |
|
API#
- apis_core.utils.helpers.datadump_get_queryset(additional_app_labels: list = [])[source]#
This method is loosely based on the dumpdata admin command. It iterates throug the relevant app models and exports them using a serializer and natural foreign keys. Data exported this way can be reimported into a newly created Django APIS app
- apis_core.utils.helpers.datadump_serializer(additional_app_labels: list = [], serialier_format='json')[source]#
- apis_core.utils.helpers.get_html_diff(a, b, show_a=True, show_b=True, shorten=0)[source]#
Create an colorized html represenation of the difference of two values a and b If show_a is True, colorize deletions in a If show_b is True, colorize insertions in b The value of shorten defines if long parts of strings that contains no change should be shortened
- apis_core.utils.helpers.construct_lookup(value: str) tuple[str, str][source]#
Helper method to parse input values and construct field lookups (https://docs.djangoproject.com/en/4.2/ref/models/querysets/#field-lookups) Parses user input for wildcards and returns a tuple containing the interpreted django lookup string and the trimmed value E.g.
example->('__icontains', 'example')*example*->('__icontains', 'example')*example->('__iendswith', 'example')example*->('__istartswith', 'example')"example"->('__iexact', 'example')
- Parameters:
value (str) – text to be parsed for
*- Returns:
a tuple containing the lookup type and the value without modifiers