[Fixed]-Double curly brace {{


The curly braces are part of Django Template Language

The part encapsulated between double curly braces {{ }} is nothing but a variable.

That’s how DTL, Jinja2 and other template languages work. They have their own set of rules which translates the template in to python and later to HTML code.



In my understanding, these braces are used to pass python variables to the HTML template. I will give you a simple use case here:
For example, I want to pass the value of a variable first_name.
In the views.py:

def my_html_template(request):
   first_name = 'John Doe'
   return render(request, 'my_html_template_name.html', {'first_name': first_name})

And then in the ‘my_html_template_name.html’, use the dictionary key to retrieve the value:

<p> {{ first_name }} </p>

This will evaluate to:

<p> John Doe </p>

Leave a comment