This tutorial covers how to create a static page (in this case an About page) in your Django project. Full accompanying code can be found on Github.


First we need to setup a virtual environment and install Django. If you need help with this, please see the following post on how to install Django, Python, virtualenv, virtualenvwrapper correctly.

$ mkvirtualenv django-about-page-three-ways
$ pip install django==1.10.2

Now let’s create a new Django project and confirm that the installation was successful:

$ django-admin startproject django_about_page_three_ways
$ python runserver

If you visit you should see the standard “Welcome to Django” page in light-blue pastel.

Templates folder and about.html file

There is often confusion over where to places a templates directory in a new Django project. The official Polls Tutorial recommends placing your templates within a dedicated templates folder for each individual app, however this quickly becomes unwieldy as a Django project grows in size.

A simpler approach advocated in Cookiecutter Django is to simply create a root-level templates folder for the entire project. That’s what we’ll do here.

Let’s update our file to change the location for our templates directory. By default, the location is set as follows:

'DIRS': [],

Update this line to the following:

'DIRS': [
        os.path.normpath(os.path.join(BASE_DIR, 'templates')),

Now create a new Templates folder and an about.html file within it:

$ mkdir templates
$ touch templates/about.html

In your text editor, add the following text to the about.html file:

# templates/about.html
<h1>About page</h1>

In Django, we need a Template, View, and URL to display a page. Our Template is done. Now let’s explore three different ways to configure our View and URL.

1) Function-Based View

The traditional way to define a view is through a function in a file. Let’s create that file within the django_about_page_three_ways project directory:

$ touch django_about_page_three_ways/

And now add the necessary logic:

# django_about_page_three_ways/
from django.shortcuts import render

def about_page_view(request):
    return render(request, 'about.html')

We import render from django.shortcuts, a helper function included by default with Django. Then we create a new function called about_page_view with the required “request” argument and pass in the name of our desired template, about.html.

Next we need to update our file so it looks like the following:

    # django_about_page_three_ways/
    from django.conf.urls import url
    from django.contrib import admin

    from .views import about_page_view

    urlpatterns = [
            about_page_view, name='about'),

We’ve added a line to import the about_page_view by name from the file. And then create a new URL pattern at “/about/”.

Run the internal Django server to see our completed page:

$ python runserver

You will see our simple “About page” text at

2) Class Based View

Django includes several generic class-based views that are easy to extend and customize. We can use the TemplateView for our About page.

Update the file with the following lines:

# django_about_page_three_ways/
from django.views.generic import TemplateView

class AboutPageView(TemplateView):
    template_name = 'about.html'

We have imported TemplateView from Django’s generic display views and then created a new view, AboutPageView.

Next we need to update our file:

    # django_about_page_three_ways/
    from .views import about_page_view, AboutPageView

    urlpatterns = [
            AboutPageView.as_view(), name='about1'),

We have added AboutPageView to our imported views and then created a new URL pattern at “/about1/”.

Run our server again:

$ python runserver

The About page will be displayed at

3) URLS only approach

A third approach is to include our class-based view directly in the file. This is my preferred approach since we don’t really need a separate file given we are not making any changes to TemplateView.

Within our file add the following code:

    # django_about_page_three_ways/
    from django.views.generic import TemplateView

    urlpatterns = [
            AboutPageView.as_view(), name='about2'),

To confirm this works, run the server and visit our new page at “/about2/”.

$ python runserver

The About page will be displayed at