### Navigation

- index
- modules |
- next |
- previous |
- FeinCMS 1.7.4 documentation »

# Utilities

`feincms.utils.``copy_model_instance`(obj, exclude=None)

  Copy a model instance, excluding primary key and optionally a list of specified fields.

`feincms.utils.``path_to_cache_key`(path, max_length=200, prefix='')

  Convert a string (path) into something that can be fed to django’s cache mechanism as cache key. Ensure the string stays below the max key size, so if too long, hash it and use that instead.

`feincms.utils.``shorten_string`(str, max_length=50)

  Shorten a string for display, truncate it intelligently when too long. Try to cut it in 2/3 + ellipsis + 1/3 of the original title. The first part also try to cut at white space instead of in mid-word.

## HTML utilities

`feincms.utils.html.cleanse.``cleanse_html`(html)

  Clean HTML code from ugly copy-pasted CSS and empty elements

  Removes everything not explicitly allowed in `cleanse_html_allowed`.

  Requires `lxml` and `beautifulsoup`.

`feincms.utils.html.tidy.``tidy_html`(html)

  Process an input string containing HTML and return a tuple (xhtml, errors, warnings) containing the output of tidylib and lists of validation errors and warnings.

  Input must be unicode. Output will be valid XHTML.

## Template tag helpers

I really hate repeating myself. These are helpers that avoid typing the whole thing over and over when implementing additional template tags

They help implementing tags of the following forms:

    {% tag as var_name %}
    {% tag of template_var as var_name %}
    {% tag of template_var as var_name arg1,arg2,kwarg3=4 %}

### Navigation

- index
- modules |
- next |
- previous |
- FeinCMS 1.7.4 documentation »