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:
<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:
A finder window will open with the current directory from within the Divio Shell:
The following files are automatically created for you:
This (empty) file is used to mark directories as Python package directories.
Contains instructions for the Django admin site on how this application’s models are handled. migrations/ Database migrations for the application.
Application configuration objects store metadata for an application. These are stored here.
Description of data in the database, represented as Python code.
Application-specific test cases.
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.