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.

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 %}

Table Of Contents

Previous topic

Translations

Next topic

Views and decorators

This Page