From the course: Learning Django

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Django templates

Django templates

From the course: Learning Django

Start my 1-month free trial

Django templates

- [Instructor] Django templates are HTML files that have extra syntax. When a view calls the render function, it passes data into the template, and the template generates the HTML to show to the user. The syntax for Django templates has three pieces. A variable's value is shown when the variable name is used inside of double curly braces. A template tag is enclosed in curly braces with percent signs. And these are used for for loops, ifs, structural elements, as well as some other control logic. Lastly, a variable can have a pipe character after it to use a template filter. Template filters take a string as input and return a string as output and can be thought of much like the pipe in shell scripting. These are mostly used to take a string and change some formatting, such as date timeout put formatting or forcing text into title or uppercase. As an example of using variables in a template, let's assume we were editing…

Contents