Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
HTML Templates | Templates
Django: Build Your First Website

HTML TemplatesHTML Templates

In Django, templates are files used to display dynamic content on your website pages. Django templates help separate logic and presentation, providing a clean and organized approach to web application development.

Key concepts of Django templates

  • Built-in Tags and Filters: Django templates have built-in tags and filters that allow you to perform various actions in the template, such as outputting variables, iterating over lists, using conditional expressions, and more;
  • Inheritance System: You can use template inheritance to create base templates containing common page elements and extend them for specific pages on your website;
  • Context Variables: Django allows you to pass data from your Python code (context) to the template so that you can display this data on the page;
  • URL Patterns: Django also uses templates to define URL patterns. You can use regular expressions and other constructs to specify the structure of your URLs;
  • Static Files: Django enables you to handle static files, such as CSS, JavaScript, and images, using special tags and functions.

The main idea is that you define the structure and appearance of your HTML code in the template, and Django fills these templates with specific data when rendering the page. This allows you to create dynamic and reusable pages in your web application.

Task

📁 Create a templates folder in the Django application folder.

¿Todo estuvo claro?

Sección 5. Capítulo 1
course content

Contenido del Curso

Django: Build Your First Website

HTML TemplatesHTML Templates

In Django, templates are files used to display dynamic content on your website pages. Django templates help separate logic and presentation, providing a clean and organized approach to web application development.

Key concepts of Django templates

  • Built-in Tags and Filters: Django templates have built-in tags and filters that allow you to perform various actions in the template, such as outputting variables, iterating over lists, using conditional expressions, and more;
  • Inheritance System: You can use template inheritance to create base templates containing common page elements and extend them for specific pages on your website;
  • Context Variables: Django allows you to pass data from your Python code (context) to the template so that you can display this data on the page;
  • URL Patterns: Django also uses templates to define URL patterns. You can use regular expressions and other constructs to specify the structure of your URLs;
  • Static Files: Django enables you to handle static files, such as CSS, JavaScript, and images, using special tags and functions.

The main idea is that you define the structure and appearance of your HTML code in the template, and Django fills these templates with specific data when rendering the page. This allows you to create dynamic and reusable pages in your web application.

Task

📁 Create a templates folder in the Django application folder.

¿Todo estuvo claro?

Sección 5. Capítulo 1
some-alt