Add an "app" to the project

We are going to use an "app" to create a basic set of pages for our website.
This will be the most basic use of an app possible. No database use is involved, this is the django equivalent of a folder of html pages.

Being unable to thing of a better name for this application, I have plumped for "homepages".
So execute this command.

~/myproject $ python manage.py startapp homepages

This lays out the following files.

neil@slim-silver ~/myproject $ tree
.
├── homepages
│   ├── admin.py
│   ├── __init__.py
│   ├── migrations
│   │   └── __init__.py
│   ├── models.py
│   ├── tests.py
│   └── views.py
├── manage.py
└── myproject
    ├── __init__.py
    ├── settings.py
    ├── urls.py
    └── wsgi.py

3 directories, 11 files

Do have a look at these files. However, we need a few more!

~/myproject $ touch homepages/urls.py
~/myproject $ mkdir -p homepages/templates/homepages
~/myproject $ touch homepages/templates/base.html
~/myproject $ touch homepages/templates/homepages/home.html
~/myproject $ touch homepages/templates/homepages/about.html

Now our project should look like this

~/myproject $ tree
.
├── homepages
│   ├── admin.py
│   ├── __init__.py
│   ├── migrations
│   │   └── __init__.py
│   ├── models.py
│   ├── templates
│   │   ├── base.html
│   │   └── homepages
│   │       ├── about.html
│   │       └── home.html
│   ├── tests.py
│   ├── urls.py
│   └── views.py
├── manage.py
└── myproject
    ├── __init__.py
    ├── settings.py
    ├── urls.py
    └── wsgi.py

5 directories, 15 files

This layout follows what I understand to be the best practice for template locations.
It may seem daft to have a folder homepages/templates/homepages but a templates dir is a special folder when django is searching for templates, and adding a second level directory with the same name as the application will help keep the namespacing tidy.

To create our first real pages, we still have some work to do, we need to edit urls.py (both of them) views.py and our html templates, and make some changes to settings.py so that our "project" is aware of our new "app".

Page 4 of 8.