Chapter 4: Generating HTML Pages with Templates

Currently, we have a Django project with URLs connected to Django views. In those views, we defined functions that return HTML code. However, placing HTML code inside Django views is not a good strategy, and affects the project maintainability and evolution. We need to move away from HTML code to their own HTML files.

In this chapter, we will discuss how Django templates work. We will learn how to connect Django views to Django templates, separating HTML code from Django view code.

In this chapter, we will be covering the following topics:

  • Understanding Django templates
  • Passing data into templates
  • Adding Bootstrap to our site
  • Adding a search form
  • Sending a form to another page

Technical requirements ...

Get Django 4 for the Impatient now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.