template filter to trim any leading or trailing whitespace

Django templates allow you to access methods and properties by using the ‘.’ syntax:

{{ var.example.strip }}

You can extend this by chaining other filters when you’re dealing with HTML, e.g.:

{{ var.example.strip|safe|removetags:"p img" }}

Here we first remove any <p> and <img> tags, then tell Django it can safely render the rest of the content, which we have stripped of any whitespace.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)