django-contentmanager 2012.5.9

A simple, pluggable content-manager for Django

  Add it to your Download Basket!

 Add it to your Watch List!


Rate it!
send us
an update
BSD License 
Peter van Kampen
ROOT \ Internet \ HTTP (WWW)
django-contentmanager is a so-called 'reusable app' to, wait for it, manage content. It does so using plugins that can be scattered over any number of apps, each providing specific types of content. A plugin could list the ten most popular news-stories, highest rated vegetarian dishes or show a selected gallery from a photo-collection app. Of course django-contentmanager could also be a block of (marked up) text.

Quick start

To try it out clone the repository and go to the demoproject-dir.

Assuming you have django on your PYTHONPATH you should be up and running with these commands:

$./ syncdb --noinput
$./ runserver

Then open your browser and go to http://localhost:8000/.

This will bring up a rather plain page (with this README) as an example of a 'paragraph'. If you follow the 'login' link you will go to the admin where you can login with test/test. In your normal project you would have to provide a nicer mechanism for your users to log in (and out) but this is just a quick demo so I'll leave that as an exercise for the reader.

Back at http://localhost:8000/ you will now see a link 'Editmode On'. This will turn on 'editmode' and allow you to add, edit and delete plugins in an, in my opion, intuitive way. Right there on the page: No need to swich back and forth between admin and 'frontend' but instant feedback.

Using the contentmanager

To use the contentmanager in your project or application you'll need to add the contentmanager to your INSTALLED_APPS in


add middleware, also in


make sure your project uses the request-context-processsor:


and finally include contentmanager.urls in your and run autodiscover:

urlpatterns = patterns(
 (r'^contentmanager/', include('contentmanager.urls')),

from contentmanager import autodiscover

and hook up the the contentmanager in your template(s):

{% load contentmanagertags %}
{% block content %}
{% get_area request 'content' %}
{% end block %}

{% block sidebar %}
{% get_area request 'sidebar' %}
{% end block %}

Writing plugins

Included with the demoapp are a few simple plugin examples (in basicblocks/ to give you the basic idea.

To write your own plugins you have to add a reveplugins module to you application and subclass from contentmanager.plugins.BasePlugin (or BaseModelPlugin). The most basic plugins just need to define their own render method. The render method is passed the request object and should return a (unicode) string:

class HelloWorld(BasePlugin):
 def render(self, request):
 return "Hello world"

To make the plugin available to the contentmanager and ultimately your users you need to register it:

from contentmanager import registry

Finally, to populate the registry you should include the following in your projects

from contentmanager import autodiscover

This will find all reveplugins modules in all your INSTALLED_APPS and load any registered plugins.


 The name reveplugins was chosen over simply 'plugins' to prevent naming conflicts. Since the contentmanager is distilled from reveCMS it seemed an appropriate enough name. ReveCMS itself is named afer Karel van het Reve, a dutch writer, not to be confused with his brother Gerard although he is also a fine writer.


Plugins roughly follow the same permission system as django-models. When a plugin is registered the contentmanager automatically creates add, change and delete permissions. Since these permissions could collide with model permissions all plugin permissions are kept in the contentmanager 'namespace' (linked to the content_type PluginType if you really want to know) and are appended with '_plugin'.

For example, a HTML-plugin would have the permissions 'contentmanager.add_html_plugin', 'contentmanager.delete_html_plugin', 'contentmanager.delete_html_plugin'.

Plugins have convenient has_add_permission, has_change_permission, has_delete_permission methods but if you use the proper codename as explained above you can use the standard django permissions system in both python- and templatecode.

Plugins can also add additional permissions in the same manner as django models do except that they are all 'bound' to PluginType.

Last updated on May 11th, 2012


#content manager #Django plugin #Django #content #manager #plugin

Add your review!