Posts

Showing posts from August, 2020

Django Template Tags

Image
               Django Template Tags Tags Django Web Framework ships with dozens of tags used to implement arbitrary logics right in the template.  Tags look like this:  {% tag %} . Tags are more complex than variables: Some create text in the output, some control flow by performing loops or logic, and some load external information into the template to be used by later variables. Tags provide arbitrary logic in the rendering process.  For example, a tag can output content, serve as a control structure e.g. an “if” statement or a “for” loop, grab content from a database, or even enable access to other template tags. Syntax {% tag_name %} Example Tags are surrounded by {% and %} like this: {% csrf_token %} Most tags accept arguments, for example : {% cycle 'odd' 'even' %} Commonly used Tags in Django Templates 1.      Comment Template ignores everything between {% comment %} and {% e...