Explain the use of Django's template filters and custom template tags.

Instruction: Describe how to create and use custom template filters and tags in Django.

Context: This question tests the candidate's ability to extend Django's templating engine for custom data presentation logic.

Updated

Official answer available

Read the opening below, then unlock the full answer and practical guidance.

A filter transforms a value in an expression such as {{ name|initials }}. A tag uses {% ... %} syntax and can accept several arguments or render a reusable fragment.

For an installed Django app named catalog, create an empty catalog/templatetags/__init__.py and this file:...

Related Questions