17.5.4 Replacing Flatpages

In Chapter 15: Creating Webpages with Django Flatpages, we used Django’s flatpages system to create a simple about page. The problem with this, I complained at the end of the chapter, was that the HTML for our page was hidden away in the database, away from the rest of our templates.

With GCBVs, we can replace our about flatpage with a call to TemplateView. The TemplateView is a GCBV that renders a template with no context data.

We can thus start in Example 17.32 by creating a template called about.html. In this example, it is placed in the site-wide directory, but we could also have opted to place it in our core app, depending on how we’ve decided to organize our project.

Example 17.32: Project Code

templates/site/about.html ...

Get Django Unleashed 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.