Django CMS

Django is one of the most popular open-source Python web development framework. Developers use Django to build a website from scratch. Like WordPress, Django CMS is also a Content Management System that allows the developer to customize the content from the front without opening an admin page. It is written in Django language framework with Python. Django CMS 1.0 was created by Thomas Steinacher, while Django CMS 2.0 was a complete rewrite of the system by Patrick Lauber. The administration interface supports several languages.

It has a lightweight core, which makes it easier to integrate with other software. Other existing Django applications can be integrated with Django CMS or whole new applications compatible with taking advantage of CMS's features. Its user-friendly and easy drag and drop interface makes it the go-to choice for content managers, editors, and website admins. It supports multilingual publishing by default.

Features of Django CMS

  1. Frontend Editing: Edit items directly from the frontend by double click
  2. Reusable Plugins: Django CMS plugins can be used in our apps
  3. Scalable: As the documents are organized in a tree structure, it is easy to add new nodes and integrate a Django app in the tree
  4. Editorial Workflow: An organized flow for publishing and approving the website
  5. Versioning: Each modification will create a new version of the application, letting you undo changes and trace back to older versions.
  6. Multisites: Administer multiple websites from a single admin interface.
  7. Multilanguage: It publishes the website in different languages by default, making it more internationalization.
  8. Extensive Integration: The Django CMS apps can be easily integrated with other Django applications
  9. Mature: Django CMS can be used to create large projects.
  10. Extensible: The Django applications support a wide range of plugins and can itself be used as a plugin for other Django applications.
  11. Media Asset Management: Manage assets like Pictures, Videos, Documents, etc.
  12. Scripting API: There are several Python APIs that can be used to manipulate Django CMS content.
  13. Security Features: There are several security features like SSL, LDAP Authentication, Captcha that can be implemented using third-party tools
  14. WYSIWYG editor: What You See Is What You Get editor is a highly customizable editor where you can see how your app will look while developing it.
  15. Session Management: Generate a unique session ID and store it in the database.
  16. Permission Management (User Permission): Give different rights to different users.
  17. Versatile: Any website can be developed using Django like e-commerce, scientific website, a social media website, blog site, etc.

Disadvantages

  • Unconventional Framework:  It doesn’t have any principles
  • Not suitable for Small-Scale Projects:  It has lots of unique features and requires a lot of coding thus, developers won’t like to do a lot of coding for small projects
  • Multiple Request Issue: It can not handle multiple requests simultaneously
  • Steep Learning: It’s difficult to remember lots of built-in functionalities. Python is required to use this framework.

Websites Build

  1. E-Commerce
  2. Scientific Web System
  3. Banking Systems
  4. Directories

Installation

Step 1:

Create a virtual enviroment

>virtualenv cms
created virtual environment CPython3.9.5.final.0-64 in 8383ms
  creator CPython3Windows(dest=D:\Django\cms, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\AppData\Local\pypa\virtualenv)
    added seed packages: pip==21.1.3, setuptools==57.0.0, wheel==0.36.2
  activators BashActivator,BatchActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator

Step 2:

Activate the environment

.\cms\Scripts\activate.bat && cd cms\




(cms) D:\Django\cms>

Step 3:

Install django-cms

>pip install django-cms




Collecting django-cms
  Downloading django_cms-3.9.0-py2.py3-none-any.whl (2.1 MB)
     ||||||||||||||||||||||||||||| 2.1 MB 3.3 MB/s
Collecting Django>=2.2
  Using cached Django-3.2.5-py3-none-any.whl (7.9 MB)
Collecting django-sekizai>=0.7
  Downloading django_sekizai-2.0.0-py3-none-any.whl (12 kB)
Collecting django-treebeard>=4.3
  Downloading django_treebeard-4.5.1-py3-none-any.whl (103 kB)
     |||||||||||||||||||||||||||||| 103 kB 51 kB/s
Collecting djangocms-admin-style>=1.2
  Downloading djangocms_admin_style-2.0.2-py3-none-any.whl (404 kB)
     |||||||||||||||||||||||||||||| 404 kB 192 kB/s
Collecting django-classy-tags>=0.7.2
  Downloading django_classy_tags-2.0.0-py3-none-any.whl (23 kB)
Collecting django-formtools>=2.1
  Downloading django_formtools-2.3-py3-none-any.whl (148 kB)
     |||||||||||||||||||||||||||||| 148 kB 819 kB/s
Collecting asgiref<4,>=3.3.2   Using cached asgiref-3.4.1-py3-none-any.whl (25 kB) Collecting pytz   Using cached pytz-2021.1-py2.py3-none-any.whl (510 kB) Collecting sqlparse>=0.2.2   Using cached sqlparse-0.4.1-py3-none-any.whl (42 kB) Installing collected packages: sqlparse, pytz, asgiref, Django, django-classy-tags, djangocms-admin-style, django-treebeard, django-sekizai, django-formtools, django-cms Successfully installed Django-3.2.5 asgiref-3.4.1 django-classy-tags-2.0.0 django-cms-3.9.0 django-formtools-2.3 django-sekizai-2.0.0 django-treebeard-4.5.1 djangocms-admin-style-2.0.2 pytz-2021.1 sqlparse-0.4.1

Step 4:

Create a project

django-admin startproject djangocms

Step 5:

Install the following packages in the settings file under the INSTALLED_APPS variable.

INSTALLED_APPS = [
    'djangocms_admin_style'
    #default applications
    'django.contrib.sites',
    'cms',
    'menus',
    'treebeard',
]

To use django.contrib.sites package, we need to add a variable called SITE_ID and set it to 1.

Packages like cms, menus are core django-cms packages.

Treebeard manages page and plugin tree structures.

djangocms_admin_style provides easy UI for admin components.

Step 6:

Setting Languages for CMS as required to keep the website international.

LANGUAGES = [
    ('en', 'English'),
    ('de', 'German'),
]

Step 7:

The important part of an application is to apply migrations to Django CMS database like PostgreSQL, MySQL, SQLite. The operations like admin, auth, cms, contenttypes, menus, sessions, sites are performed in migrations

(cms) D:\Django\cms\djangocms>python manage.py migrate




Operations to perform:
  Apply all migrations: admin, auth, cms, contenttypes, menus, sessions, sites
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying auth.0012_alter_user_first_name_max_length... OK
  Applying sites.0001_initial... OK
  Applying cms.0001_initial... OK
  Applying cms.0002_auto_20140816_1918... OK
  Applying cms.0003_auto_20140926_2347... OK
  Applying cms.0004_auto_20140924_1038... OK
  Applying cms.0005_auto_20140924_1039... OK
  Applying cms.0006_auto_20140924_1110... OK
  Applying cms.0007_auto_20141028_1559... OK
  Applying cms.0008_auto_20150208_2149... OK
  Applying cms.0008_auto_20150121_0059... OK
  Applying cms.0009_merge... OK
  Applying cms.0010_migrate_use_structure... OK
  Applying cms.0011_auto_20150419_1006... OK
  Applying cms.0012_auto_20150607_2207... OK
  Applying cms.0013_urlconfrevision... OK
  Applying cms.0014_auto_20160404_1908... OK
  Applying cms.0015_auto_20160421_0000... OK
  Applying cms.0016_auto_20160608_1535... OK
  Applying cms.0017_pagetype... OK
  Applying cms.0018_create_pagenode... OK
  Applying cms.0019_set_pagenode... OK
  Applying cms.0020_old_tree_cleanup... OK
  Applying cms.0021_auto_20180507_1432... OK
  Applying cms.0022_auto_20180620_1551... OK
  Applying menus.0001_initial... OK
  Applying sessions.0001_initial... OK
  Applying sites.0002_alter_domain_unique... OK

Step 8:

Create Super User.

(cms) D:\Django\cms\djangocms>python manage.py createsuperuser




Username (leave blank to use ' '): user1
Email address: abc@gmail.com
Password:
Password (again):
This password is too common.
Bypass password validation and create user anyway? [y/N]: y
Superuser created successfully.

When python manage.py createsuperuser is executed, it will ask for the username you want to give, or by default, it is the computer user . After entering the username, the email address is asked and then the password. If the password is common, it will ask if validation is to be bypassed and you want to use the password.

Step 9:

Check if all the necessary packages are installed

(cms) D:\Django\cms\djangocms>python manage.py cms check
←[1m********************************←[0m
←[1mChecking django CMS installation←[0m
←[1m********************************←[0m




←[1mSekizai←[0m
←[1m=======←[0m




  - Sekizai is not installed, could not find 'sekizai' in INSTALLED_APPS ←[31;1m[ERROR]←[0m
  - Sekizai template context processor is not installed, could not find 'sekizai.context_processors.sekizai' in TEMPLATES option context_processors ←[31;1m[ERROR]←[0m




←[1mInternationalization←[0m
←[1m====================←[0m




  - New style CMS_LANGUAGES ←[32;1m[OK]←[0m




←[1mMiddlewares←[0m
←[1m===========←[0m




  - django.middleware.locale.LocaleMiddleware middleware must be in MIDDLEWARE ←[31;1m[ERROR]←[0m
  - cms.middleware.user.CurrentUserMiddleware middleware must be in MIDDLEWARE ←[31;1m[ERROR]←[0m
  - cms.middleware.page.CurrentPageMiddleware middleware must be in MIDDLEWARE ←[31;1m[ERROR]←[0m
  - cms.middleware.toolbar.ToolbarMiddleware middleware must be in MIDDLEWARE ←[31;1m[ERROR]←[0m
  - cms.middleware.language.LanguageCookieMiddleware middleware must be in MIDDLEWARE ←[31;1m[ERROR]←[0m




←[1mContext processors←[0m
←[1m==================←[0m




  - cms.context_processors.cms_settings context processor must be in TEMPLATES option context_processors ←[31;1m[ERROR]←[0m




←[1mPlugin instances←[0m
←[1m================←[0m




  - Plugin instances of 0 types found in the database ←[32;1m[OK]←[0m




The plugins in your database are in good order ←[32;1m[OK]←[0m




←[1mPresence of "copy_relations"←[0m
←[1m============================←[0m








All plugins and page/title extensions have "copy_relations" method if needed. ←[32;1m[OK]←[0m




←[1mPlaceholderField←[0m
←[1m================←[0m




PlaceholderField configuration okay ←[32;1m[OK]←[0m




←[1mOVERALL RESULTS←[0m
←[1m===============←[0m




←[31;1m8 errors!←[0m
←[32;1m5 checks successful!←[0m




←[31;1mPlease check the errors above←[0m




CommandError:

The first error statingsekizai is not installed can be resolved by installing it in settings.py under the INSTALLED_APPS variable.

To remove the template errors, add the following in TEMPLATES in settings.py

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
#others
                'cms.context_processors.cms_settings',
                'django.template.context_processors.i18n',
                'sekizai.context_processors.sekizai',
               




            ],
        },
    },
]

To remove middleware errors, add the following in MIDDLEWARE in settings.py

MIDDLEWARE = [
    #other middlewares
    'django.middleware.locale.LocaleMiddleware',
    'cms.middleware.user.CurrentUserMiddleware',
    'cms.middleware.page.CurrentPageMiddleware',
    'cms.middleware.toolbar.ToolbarMiddleware',
    'cms.middleware.language.LanguageCookieMiddleware',
]

After successful check the output looks like:

←[1m********************************←[0m
←[1mChecking django CMS installation←[0m
←[1m********************************←[0m




←[1mSekizai←[0m
←[1m=======←[0m




  - Sekizai is installed ←[32;1m[OK]←[0m
  - Sekizai template context processor is installed ←[32;1m[OK]←[0m




Sekizai configuration okay ←[32;1m[OK]←[0m




←[1mInternationalization←[0m
←[1m====================←[0m




  - New style CMS_LANGUAGES ←[32;1m[OK]←[0m




←[1mMiddlewares←[0m
←[1m===========←[0m








←[1mContext processors←[0m
←[1m==================←[0m








←[1mPlugin instances←[0m
←[1m================←[0m




  - Plugin instances of 0 types found in the database ←[32;1m[OK]←[0m




The plugins in your database are in good order ←[32;1m[OK]←[0m




←[1mPresence of "copy_relations"←[0m
←[1m============================←[0m








All plugins and page/title extensions have "copy_relations" method if needed. ←[32;1m[OK]←[0m




←[1mPlaceholderField←[0m
←[1m================←[0m








PlaceholderField configuration okay ←[32;1m[OK]←[0m








←[1mOVERALL RESULTS←[0m
←[1m===============←[0m




←[32;1m8 checks successful!←[0m




←[32;1mInstallation okay←[0m

Now, we are ready to create our CMS project.


Related Topics

Django MVT

 MVT(Model View Template) MVT means Model View Template is a software design pattern The View is used to implement the business logic and to communicate with a model for data transmission and to...

2 minutes read.

Django Stack

Django is a popular Python web application framework that adheres to the "batteries-included" tenet. Batteries-guiding included idea is that common functionality for creating web applications should be provided with the...

5 minutes read.

Django Model Fields

In Django, if we want to store the information about anything, we use Models. It contains various fields about the data. Generally, each model represents a database where all the...

4 minutes read.

Django Framework

Django is a popular high-level open-source web development Python framework based on follows Model View Template (MVT) architecture that allows rapid development. It. It provides common functionality like Admin Interface,...

3 minutes read.

Django All Auth

For any web application, user registration and authentication are the essential parts. In Django, there are several applications like django-registration-redux to perform these tasks, but the major drawback is that...

6 minutes read.

How to create an app in Django

Create an application in Django Django is famous for its unique and fully managed application structure. For each functionality, an application can be created as a completely independent module. This article will take...

2 minutes read.

Django ORM

Django is a Python web framework that enables easy and quick web development. Django has a handy and powerful feature called Django Object Relational Mapper, also known as Django ORM,...

3 minutes read.

Django Installation

Django Installation Django development environment consists of installing and setting up Python, Django, and a Database System since Django deals with a web application. Below the statement will guide you through installing Python 3.8.0 and...

2 minutes read.

What is Django?

What is Django? Django is a free and open-source web application framework, written in Python. A web framework is a set of components that help you develop an easier and faster website. When we...

3 minutes read.

Django CMS

Django is one of the most popular open-source Python web development framework. Developers use Django to build a website from scratch. Like WordPress, Django CMS is also a Content Management...

9 minutes read.

Django Create App

Django is a Python-based web framework that is based on the Model View Template architecture. In this post, we will go through the installation and setup for our first Django...

4 minutes read.

Django Project

Django Project Let's start to use it. Each web app you want to build in Django is called a project; and a project is a collection of apps. A software is a series of...

3 minutes read.

Features of Django

Features of Django Offers High Security:- Django is super secure. To prove the feature, we can always take examples of lots of websites which are present worldwide and possess huge traffic. Django is secure because it covers the...

3 minutes read.

Django Channels

Channels is a project that uses Django and adds some functionalities beyond the traditional HTTP by using WSGI and ASGI.  We can use both synchronous and asynchronous requests with ASGI...

5 minutes read.

Django CSRF

Django is a high-level python based web framework. Django is open source and free to use for all. Django provides many features to web developers like scalability, security, rapid development,...

4 minutes read.

Django Template System

Django Template System Django allows Python and HTML to be divided, the Python goes into views, and HTML goes into templates. Django relies on the render feature and the language of the Django Model...

5 minutes read.

Django Logging

Every application developed has some bugs and errors. It is the responsibility of the developers to maintain the application by making it bug-free and error-free. To debug the application code...

5 minutes read.

Django Image Upload

Django is a python based web framework that uses Model View Template as its architecture. Django provides really quick web development with its functionalities. While we are building a website,...

3 minutes read.

Django Messages

Django Framework Django is a framework that can make web applications more accessible and faster. Django is an open-source collection of python libraries, and Django can be used for both the...

6 minutes read.

Uses of Django

Django is a free and open-source Python-based web framework, which offers great functionalities to its users. Django was developed in 2003, and the final version was released in 2008 by...

3 minutes read.