In the previous section, I talked about the Django template syntax. You can use Django to display the data in the view on the page. This section mainly describes the Django template filter.
Django template character Truncation
Slice
Returns a slice of the list.
Example:
{Some_list | slice: ": 2 "}}
If some_list is ['A', 'B', 'C'], the output will be ['A', 'B'].
Remove HTML format from Django Template
Striptags
Strips all [x] HTML tags.
For example:
{Value | striptags }}
If value is"JoelIsSlug", The output will be" Joel is a slug ".
Template obtains the string length
Returns the length of the value. This works for both strings and lists.
For example:
{Value | length }}
If value is ['A', 'B', 'C', 'D'], the output will be 4.
If you want to learn more about the format and syntax of Django template. See the relevant documents.
We recommend that you read: About the configuration of the Django SQLite database and share your experiences with select_related ().