Jonas Obrist Python enthusiast


Apphooks vs Plugins

Dec. 6, 2012

A question that comes up quite often on the django CMS IRC channel is when it's appropriate to use Apphooks as opposed to Plugins.

To answer this question, we have to understand what Apphooks and Plugins are.


An Apphook is, as the name suggests, a way for a (Django) app to hook itself into the CMS. As a result, an Apphook is responsible for the rendering of one or multiple complete pages, and has an easy way of extending the menu system to include these pages it controls. They can handle any type of request and control the whole response, not just a part of it. An Apphook is hooked into the CMS exactly once (per language). Apphooks do not support dynamic configuration by default.


A Plugin is, again as the name suggests, a plugin to the CMS. More specifically, it's a plugin into a CMS Page. It usually only controls a small part of a page and can only process GET requests reliably. A Plugin can be on as many pages as the user desires. Plugins can be dynamically configured on a per-instance basis.


Reading the above it becomes clear that the two things are very different ways of adding content to django CMS. So answering a few questions makes it clear which you should use:

  • Do I need more than one page for what I'm building? If yes, use an Apphook.
  • Do I need to handle POST requests? If yes, use an Apphook.
  • Does my data result in a logical page hierarchy? If yes, use an Apphook.

Note that Apphooks and Plugins are by no means mutually exclusive, many Apphooks also provide Plugins.


Let's use the official Django tutorial app as an example. Reading the questions above it becomes pretty clear that this needs an Apphook. Why? Because each poll will have its own page and it needs to handle POST requests for voting. However, it will most likely still make sense to build a Plugin for it, to display a single poll on an arbitrary CMS Page, for example to feature the latest poll on your homepage.

comments powered by Disqus