{% %} and {{ }} in Django

前端 未结 3 1509
北海茫月
北海茫月 2021-01-31 19:32

I am learning Django and came across 2 sets of special characters that I haven\'t seen used like this before. I can guess what they are used for in the examples, but don\'t unde

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-31 20:28

    {% %} and {{ }} are part of Django templating language. They are used to pass the variables from views to template. {% %} is basically used when you have an expression and are called tags while {{ }} is used to simply access the variable.

    For more information, I suggest have a look at :

    https://docs.djangoproject.com/en/1.9/ref/templates/language/#variables

提交回复
热议问题