Wagtail is a Python-based CMS made for Django. The Wagtail CMS was released in 2015 by a digital agency named Torchbox, the same agency that created South migrations for Django in 2008. So when we encountered a project that required a content management system, we had an additional reason to give Wagtail CMS a try. We decided to try it out in practice.
Compared to other famous content management systems like Django Content Management System, which provides a ton of flexibility to the administrator (content manager) at the cost of interface complexity, the Wagtail CMS has a rather simple interface with minimum settings. And all of these settings and functionality have to be implemented in code. Content managers can only use a set of tools that are implemented programmatically as Python classes or so-called blocks.
We use Wagtail for the CMS (content management system) in the Django rest framework. Because for cms, we need to create templates for every API but
Wagtail provides its admin with a frontend interface. We connect Django rest APIs to the wagtail framework with wagtail models.
models.py
For Django, we install Wagtail through pip
$ pip install wagtail
After installing Wagtail, we setup the configuration in the settings.py file in the installed apps:
Settings.py
Add the wagtail Site name in settings.py. This will be displayed on the main dashboard of the Wagtail admin backend:-
We configure urls.py in our project directory with the wagtail URLs
urls.py
wagtailadmin_urls provides the admin interface for Wagtail. This is separate from the Django admin interface:-
Login admin in Wagtail
In the Wagtail CMS, pages are Django models. Pages inherit from the abstract Wagtail Page model, which has all the service methods, fields, and properties needed by a page. We use Rich Text Field in our Django ems project, so we implement wagtail models:-
models.py
In EMS projects, we use different — 2 Wagtail models for many purposes like: for birthday (BirthdayPage Model), upcoming holiday (UpcomingHoliday Model), etc. We’ve used a standard Django CharField in these models and a field from the Wagtail CMS called RichTextField.
To be able to preview our new page, we need to create a template for it. A template file must be placed either in the project’s templates directory (under the blog subdirectory) or inside the application templates directory. It must be named exactly like in the model.
The page will automatically be registered in the admin interface, so all left is to create and apply a migration.
For example, we open a birthday page this looks like this, and we fill in all the details on this page. We can view all data in Django, admin form wagtail admin.
Django-admin View of pages:
Here wagtail data is showing in the Django-admin table
Django-cms and Wagtail are both based on the Django framework. It is very similar to the classic Django-admin page. The Django CMS admin style overrides Django admin’s base_site.html, but you can still partially customize this page.
Django-CMS might use the Django admin as its admin page; it creates custom templates to make the page look more decent. But this implementation also brings some problems. If your existing application, which has an existing admin app, wants to integrate Django-CMS to add some CMS functions, Django-CMS might not work very well in this scenario.
Django-CMS is not more flexible than Wagtail because, in Wagtail, we easily extend the model and integrate CMS into your existing project.
In today's interconnected world, businesses rely on digital platforms for almost every aspect of their… Read More
Corporations are increasingly expected to lead by example as the global community becomes more aware… Read More
The workplace has transformed dramatically in recent years, driven by rapid technological advancements and global… Read More
In today's fast-paced digital landscape, businesses are constantly searching for ways to stay ahead of… Read More
In the ever-evolving landscape of website development, selecting the right Content Management System (CMS) is… Read More
Education is a realm constantly evolving with technological advancements. Augmented Reality (AR) and Virtual Reality… Read More