Stop those deprecation warnings

towel.utils.changed_regions(regions, fields)

Returns a subset of regions which have to be updated when fields have been edited. To be used together with the {% regions %} template tag.


regions = {}
render(request, 'detail.html', {
    'object': instance,
    'regions': regions,
return HttpResponse(
    json.dumps(changed_regions(regions, ['emails', 'phones'])),
towel.utils.parse_args_and_kwargs(parser, bits)

Parses template tag arguments and keyword arguments

Returns a tuple args, kwargs.


def custom(parser, token):
    return CustomNode(*parse_args_and_kwargs(parser,

class CustomNode(template.Node):
    def __init__(self, args, kwargs):
        self.args = args
        self.kwargs = kwargs

    def render(self, context):
        args, kwargs = resolve_args_and_kwargs(context, self.args,
        return self._render(context, *args, **kwargs):

    def _render(self, context, ...):
        # The real workhorse

Return all classes which would be deleted if the passed instance were deleted too by employing the cascade machinery of Django itself. Does not return instances, only classes.

Note! When using Django 1.5, autogenerated models (many to many through models) are returned too.

towel.utils.resolve_args_and_kwargs(context, args, kwargs)

Resolves arguments and keyword arguments parsed by parse_args_and_kwargs using the passed context instance

See parse_args_and_kwargs for usage instructions.

towel.utils.safe_queryset_and(head, *tail)

Safe AND-ing of querysets. If one of both queries has its DISTINCT flag set, sets distinct on both querysets. Also takes extra care to preserve the result of the following queryset methods:

  • reverse()
  • transform()
  • select_related()
  • prefetch_related()
towel.utils.substitute_with(to_delete, instance)

Substitute the first argument with the second in all relations, and delete the first argument afterwards.

towel.utils.tryreverse(*args, **kwargs)

Calls django.core.urlresolvers.reverse, and returns None on failure instead of raising an exception.