These are special tokens that appear in django templates. You can read more about syntax in the link to the django template language in the documentation.
{{ foo }} is the placeholder in the template, for the variable foo, which is passed to the template from the view.
{% %} - when the text is surrounded by these delimiters, it means that there is some special function or code, and the result of this will be placed here. It is used when the text inside is not passed to the template from the view, but rather a function or function of the template language itself, which is executed (for example, a for loop or conditional if condition). You can create your own extensions for the template language, which are called template tags.
{{ foo|something }} is another syntax you may come across. |something is a template filter. This is usually a conversion of the result of the element to the left of the | . For example, {{ foo|title }} .
Read more about tags and filters called template builtins in the documentation.
This syntax is not unique to django - many other template languages ββin Python (and some outside Python) have adopted a similar syntax.
Python does not have the same syntax, but has the concept of string patterns , which is a very simplified version of the engine pattern.
Burhan khalid
source share