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 Admin

To manage the content of the website, e.g., adding and deleting posts, web developers need an admin portal on the website. The admin portal allows trusted users, also knows as...

3 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.

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 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.

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 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.

How to Implement Multiple User Types with Django

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...

3 minutes read.

Django Model

Django Model A template is a class representing a table or collection in our DB and where each class attribute is a table or collection area. In the app / models.py, models are...

6 minutes read.

Django Create Project

Django is an open-source free to use web framework which is based on Python. Django uses Model-View-Template as its architecture. The final version of Django was released in 2008. Django...

4 minutes read.

Django Frontend

Django 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 front...

3 minutes read.

Life Cycle of Django

Life Cycle of Django Request - Response life cycle in Django  Thebasic principle of http protocol is the client sends a request to the server based on the request data, and the server sends...

3 minutes read.

Django – Sending E-mails

Django – Sending E-mails Django comes with a light engine that is ready and simple to use to send emails. Similar to Python, you just need to import a smtplib. You just need to import django.core.mail in Django. Edit the project settings.py file to start sending emails and set  all the following options: EMAIL_HOST – server with smtp.EMAIL_HOST_USER – smtp server login key.EMAIL_HOST_PASSWORD ? Password credential for the smtp server.EMAIL_PORT – server port smtp.EMAIL_USE_TLS or _SSL – if it is secure connection then set True. Simple E-mail Sending To submit a simple e-mail, let's create it a "simpleEmail" view. from django.core.mail import...

3 minutes read.

Creating View in Django

Creating View in Django    Django views are a key component of the frameworkbased applications.We are using Python function or class at their simplest, which takes up a web query and returns a web response.Views are used to get objects from the server, change objects if needed, render types, return HTML, and much more. Class Based View and Function based Django has two types of views: views based on functions (FBVs) and views based on class (CBVs).Initially, Django began with only FBVs, but then introduced CBVs as a way to model features so we didn't have to write boilerplate (i.e. the same software) code again and again.CBVs would be a way to increase efficiency, so you don't have to write as much code as you can. CBVs are classes of Python at their heart. Django ships with a range of "model" CBVs with pre-configured features that can be reused and often expanded.Then helpful names are given to these classes that explain what kind of functionality they provide.These are often referred to as "universal views" because they provide solutions to specific needs. The classes have a journal View function, or "view" for short, is simply a Python program that uses a web query and returns a web response. This response may include the HTML content of a web page, or a redirect, or a 404 error, or an XML file, or an image, etc. Example: You use a view to create a web page, remember that you need to connect a view to a URL to see it as a web page. Simple View We will create a simple view in myapplication to say “Welocome to django application” See the following view – from django.http import HttpResponse ...

4 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 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 Authentication

Django is an open-source free to use web framework which is based on Python. Django uses Model-View-Template as its architecture. The final version of Django was released in 2008. Django...

4 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.

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 Tutorial

Django Introduction It is a web application framework written in a python programming language. It based on the MVT( Model View Templet) design pattern. It takes a short time to build an application...

2 minutes read.

Best Django courses

In this tutorial, we will see various courses in python Django available on the internet. Django has become popular these days, so courses on it are also increasing day by...

7 minutes read.