How to write a plugin


Plugins will be phased out in 2.1.0 when we update to Django 1.7.

A plugin is basically just a normal Django application. The only thing making it a pugin is that it integrates itself into the Devilry system in some way.

Setting up your testsite

In this howto we assume you have created a django site, mysite/, and and that your plugin is a application in this site called myplugin. It should look something like this:


Autoload plugins

There are several ways a plugin can integrate itself, but they all need some place to do the integration. Just like can be used to integrate your application with the Django admin interface, devilry provides a place where you can put code that you want to autoload.

First initialize the plugin system by adding:

from devilry.apps.core import pluginloader

to your mysite/, making it look something like this:

from django.conf.urls import *

# Uncomment the next two lines to enable the admin:
#from django.contrib import admin

from devilry.apps.core import pluginloader

urlpatterns = patterns('',
    # Example:
    # (r'^mysite/', include('')),

    # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
    # to INSTALLED_APPS to enable admin documentation:
    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    # (r'^admin/', include(,

pluginloader.autodiscover() will autoload any module named devilry_plugin in any application in INSTALLED_APPS.

Your first plugin

Create a file named mysite/myplugin/, and put the following code into the file:

print "Hello plugin world!"

Start the development server with python runserver, go to http://localhost:8000/ and you should see the message you printed in the terminal/shell running the server.

Plugin errors

pluginloader.autodiscover() will fail if you have any errors in your devilry_plugin-module. It will not auto-reload failed modules before you restart the server.