tools

Utility-functions used by some of the other apps.

exception nano.tools.SiteProfileNotAvailable
nano.tools.asciify(string)

Convert unicode string to ascii, normalizing with NFKD

Strips away all non-ascii symbols

nano.tools.grouper(n, iterable, fillvalue=None)

grouper(3, ‘ABCDEFG’, ‘x’) –> ABC DEF Gxx

Models

Tree

Denoramlized text-field

Model with one generic foreign key

Template tags

Either import the tags into some other templatetags-library. or add 'nano.tools' to INSTALLED_APPS.

nano.tools.templatetags.nano_tags.come_back(context)

Turn current url path into a query-part for use in urls

With default template:

If the path is stored in the context as /foo/bar, tag returns ‘?next=/foo/bar’

nano.tools.templatetags.nano_tags.endswith(value, arg)

Usage {% if value|endswith:”arg” %}

nano.tools.templatetags.nano_tags.fraction(text, arg=1)

Get fractional part of float, pad with zeroes until <arg> length

nano.tools.templatetags.nano_tags.integer(text)

Get integer-part of float

nano.tools.templatetags.nano_tags.nbr(*args, **kwargs)

Replace whitespace with non-breaking-space

nano.tools.templatetags.nano_tags.partition(iterable, cols=4)

Split an iterable into columns

nano.tools.templatetags.nano_tags.startswith(value, arg)

Usage {% if value|startswith:”arg” %}