Django-CMS #1 PART

Alex Blashchuk | Nov. 20, 2023 | Category: DJANGO

Django-cms is a powerful instrument powered by Django. It’s become easy to create modern and flexible websites that can be edited at any time. Django-cms is a direct competitor to Wordpress, but at the same time has all the advantages of the Django framework.

The setup is incredibly simple. I will set up a project using docker demo image. First of all, install Docker from here.

The demo project is a minimal django project with some additional requirements in the requirements.txt.

Open the terminal application on your computer and go to a safe folder, then:

git clone
cd django-cms-quickstart
docker compose build web
docker compose up -d database_default
docker compose run web python migrate
docker compose run web python createsuperuser
docker compose up -d

During the installation process, you will be prompted to enter your email address and set a username and password. Open your browser and insert http://localhost:8000/admin there you should be invited to login. You will see the following page:

Now our project works well, but Django CMS requires a relational database backend. Each django CMS installation should have its own database. Let’s do this first. Navigate to file in the backend directory and find a DATABASE_URL and DATABASES variables.

DATABASE_URL = os.environ.get('DATABASE_URL', 'sqlite://:memory:')
DATABASES = {'default': dj_database_url.parse(DATABASE_URL)}

DATABASE_URL contains a database url from the .env-local file. If the file doesn’t contain DATABASE_URL variable, it will be placed default value 'sqlite://:memory:'. So, navigate to the .env-local file and we will change DATABASE_URL variable.


Look at DATABASE_URL. It says to use PostgreSQL database, with a username “postgres” and a password “password”, connect to a database “db” via 5432 port. We will leave admin username and password (I STRONGLY RECOMMEND NOT ALLOWING SUCH PASSWORDS IN THE PRODUCTION OF YOUR PROJECT), but change database name to ‘django_cms_blog’.


Next, open the docker-compose.yml file, and change the POSTGRES_DB variable in “database_default” service to ‘django_cms_blog’:

    # Select one of the following db configurations for the database
    image: postgres:13.5-alpine
      - "5432:5432/tcp"  # allow your local dev env to connect to the db
      POSTGRES_DB: "django_cms_blog"
      POSTGRES_PASSWORD: "password"
      SERVICE_MANAGER: "fsm-postgres"

      - djangocmsnet

      - ".:/app:rw"

Now let’s rebuild our docker container.

docker compose up -d --build

After the containers were created successfully, we will check logs.

docker ps

docker logs 29a95

docker logs 496d22

Now we get errors that database ‘django_cms_blog’ does not exist and that’s normal. We haven’t created the database yet. Let’s do it:

docker-compose exec database_default createdb -U postgres -W django_cms_blog

Enter password of your PostgreSQL, make migrations and create new super user.

docker-compose run web python migrate
docker-compose run web python createsuperuser

Now rebuild your containers again, open your browser and insert http://localhost:8000/admin. After successful login you will see a welcome page.

Now you can create and publish your first page. In the next chapter, we will add a custom HTML template and create the first application.