Skip to main content

urlizetrunc

Convert URLs into clickable links, truncating URLs to the given character limit, and adding 'rel=nofollow' attribute to discourage spamming.

def urlizetrunc(
value: string,
limit: int,
autoescape: boolean = True
) - > string

Convert URLs into clickable links, truncating URLs to the given character limit, and adding 'rel=nofollow' attribute to discourage spamming.

Parameters

NameTypeDescription
valuestringThe input text containing URLs to be converted into clickable HTML links.
limitintThe maximum character length for the displayed link text before it is truncated.
autoescapeboolean = TrueIndicates whether the input text and resulting HTML should be automatically escaped to prevent XSS attacks.

Returns

TypeDescription
stringThe processed string containing HTML anchor tags with truncated link text and nofollow attributes, marked as safe for Django templates.