In the next parts, we’ll cover how you can add a new Django app to your existing project, which will extend the basic CMS “Page” with two additional “Extra settings”:

  • Subtitle - for displaying a subtitle underneath our header.
  • Background Image - for displaying a custom background image in our header.

This change will enable us to set a title, subtitle and custom header background image directly from the Page settings and keeps our content clean, as shown in the example below:

To get started, open the Divio App and click on "Divio Shell":

Next, navigate to your project folder inside the Divio workspace directory:

cd <project-name>

Replace “<project-name> ” with the project name (slug), which is the name of your project in lower case separated by dashes. You can also list all available options by typing in ls and then use cd <project-name> .

docker-compose run --rm web python manage.py startapp my_custom_page_extension

This command will generate a Django application located in “<your_project_directory>/my_custom_page_extension .” You can open your projects directory by running:

open .

A finder window will open with the current directory from within the Divio Shell:

The following files are automatically created for you:

  • __init__.py
    This (empty) file is used to mark directories as Python package directories. 
  • admin.py
    Contains instructions for the Django admin site on how this application’s models are handled. migrations/ Database migrations for the application.
  • models.py
    Description of data in the database, represented as Python code.
  • tests.py
    Application-specific test cases.
  • views.py
    View functions for your application. 

If you don’t understand what each files does, don’t worry. We’ll cover the relevant aspects shortly, with example code and details in info boxes.

Did this answer your question?