Creating templates for your views

We have created views and URL patterns for the blog application. Now, it's time to add templates to display posts in a user-friendly manner.

Create the following directories and files inside your blog application directory:

templates/    blog/        base.html        post/            list.html            detail.html

The preceding structure will be the file structure for our templates. The base.html file will include the main HTML structure of the website and divide the content into the main content area and a sidebar. The list.html and  detail.html files will inherit from the base.html file to render the blog post list and detail views, respectively.

Django has a powerful template language that allows you to specify how data is displayed. It is ...

Get Django 2 by Example 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.