Content: Blog

Technical articles

No program is an island - integrate your applications with django CMS

Daniele Procida

Feb. 8, 2016

integration

One area in which django CMS truly shines is its ability to integrate seamlessly with other applications. Here's a run-down of the approach django CMS takes, and how you can benefit from it in your own projects.

If you want a CMS, you're spoilt for choice. Even if you want a Django-based CMS, there are a number of good options to choose from that suit different needs.

We know however that many of our users didn't just want a CMS: they wanted a CMS that would integrate well into their other Django applications - so let's look at how django CMS does this.

 

In the early days...

Right from the start, we knew that many of our users were already using, or had planned, data-driven Django applications, of all different kinds.

We couldn't afford to make assumptions about what their applications and sites would look like - their URL structures, their templates, their look and feel - they might all be different from our own, and from each other.

Even though we could make a fairly reliable bet that many users would want to publish information about things like people, news, events and so on, we couldn't make assumptions about how they would.

 

Our approach

So we didn't make any assumptions.

We decided that rather than build a CMS that tried to manage information about things like people, news or events, we'd leave that to other applications instead, and make sure that those applications could be integrated easily and seamlessly into django CMS.

Our approach is based on a few core principles. django CMS should:

  • manage free-form content that human beings produce, not structured information that programs can handle
  • allow third-party dedicated applications to manage and publish structured information
  • provide easy ways to reuse information from other applications
  • coexist in a trouble-free way alongside other applications
  • make publishing management tools and site infrastucture (such as menu systems) easily available to other applications

 

Success!

It's an approach that has paid off well. Alongside django CMS a flourishing ecosystem of third-party addons has grown up. There's not just one way to publish information about news or events with a django CMS site now, there are several.

There are programs in the ecosystem to meet all the needs we imagined, and many that we hadn't.

What's more, many applications that weren't initially designed to integrate into django CMS at all have been extended to do just that, and take advantage of the ways in which other applications can make use of its publishing features - with only a little extra work.

 

How to do it

Different use-cases need different kinds and levels of integration, so it's simply a question of finding a way that suits your needs. django CMS offers integration through...

 

Plugins

A plugin is the easiest way to integrate any other Django application with django CMS (in fact it's so simple, we do it in the third page of the django CMS tutorial).

A plugin is used to place content in a django CMS page, or indeed any page that makes use of django CMS placeholders.

Some plugins are intended to contain human-authored content, but they can also deliver content programmatically, from any part of the Django system (i.e. anything in the database, so for example a list of latest news items) or even beyond (using APIs to fetch data from other sources, for example a feed of meteorological data).

A third-party application can be entirely independent of django CMS and still offer optional plugins for those users who also use django CMS. There are several applications that follow this pattern: you don't need to use django CMS, but if you do, there's some extra useful functionality available.

Plugins are easy to write and well-documented.

 

Apphooks

To integrate an application more closely with django CMS, you can use an apphook, which "hooks" the application into django CMS's menu structure at whichever point you choose. Your news application (for example) now appears to visitors as a django CMS page; its own URL structure is neatly integrated into django CMS's too.

In the simplest case, this takes just a handful of lines of code

 

The Toolbar

The django CMS toolbar offers quick access to key operations and parts of the system. However, it's not exclusively for django CMS's use: it's extensible, and you can add your own controls to it very easily.

For a simple example, your application may manage events; you could add a toolbar item to let you get quickly to the list of events in the Django admin. Once again, it's just a few lines of code to get started.

 

Content creation wizards

Often, users need to create a new page or other item quickly. The standard Django admin forms are complete, but sometimes overkill for a quick addition of this sort. This is where content creation wizards come in: they present just the key fields required for creating a new item.

This can be a page, as noted, but the wizards are easily adopted in your own applications, for any kind of content or information. If your application manages news or people, it will take just a few lines of code to add a new wizard to the system to handle them.

 

django CMS placeholders in your own applications

One of the jewels in django CMS's crown is the placeholder/plugin architecture, and it's one of the key features behind its success.

What you may not know is that the same architecture is available to your own applications too, which means you can benefit from a very powerful content publishing system, and ensure that the entire suite of applications in your project enjoys a consistent interface for your users.

 

Menus

Our menu system is actually a separate application from the CMS module, even though its part of the same package. That's because we didn't want it to be tied to django CMS. Like any other application, django CMS speaks to the menu system via an API.

This means that your own applications can interact with the menu system as an equal citizen. You can do pretty much what you like with menus: insert nodes linking to other resources (or entire hierarchies of nodes) programmatically, attach menus to pages, and more.

Tapping into the menu system implies a fairly deep level of integration. Unlike most of the other forms of integration, it implies a strong commitment to django CMS as part of a web project. It's also somewhat more complex to implement, but extremely flexible and powerful and well-documented.

 

A bonus for all

If your application offers integration with django CMS, it's immediately more attractive to the vast number of django CMS developers who build projects with it, and an excellent way for your open-source project to acquire more traction.

Sometimes developers are torn between the prospects of building a new application to perform a key function or stitching an existing one into their project - django CMS's integration features provide an elegant way to sidestep that dilemma. 

Let us know about your application and how it integrates with the CMS; we'll be happy to help promote it to the community of django CMS developers and users.

blog comments powered by Disqus

Do you want to test django CMS?

Try django CMS