Web users commonly recognize URLs without the protocol (http://) or trailing slash (/), and, similarly, they will enter URLs in this fashion in address fields. In this recipe, we will create a humanize_url filter that is used to present URLs to the user in a shorter format, truncating very long addresses, similar to what Twitter does with the links in tweets.
Creating a template filter to humanize URLs
Getting ready
Similar to the previous recipes, we will start with the utils app that should be set in INSTALLED_APPS in the settings and contain the templatetags package.