I recently refactor the KermIT project to get a completely dynamic project and have the ability to add plugins.
Here I’m going to show you how to check for “installed plugins” and automatically configure the urls.
First of all you have to configure a Django app, named for example plugins and correctly link it up to your Django project. So add it to INSTALLED_APPS in the settings.py file and add it to global urls.py
urlpatterns = patterns('', (r'^plugins/', include('webui.plugins.urls')), )
Then in the plugins app create a urls.py module like this one:
from django.conf.urls.defaults import patterns, include import logging from webui.plugins import utils logger = logging.getLogger(__name__) urlpatterns = patterns('', ) installed_plugins = utils.installed_plugins_list() for plugin in installed_plugins: try: urlpatterns += patterns('', (r"^%s/" % plugin, include("webui.plugins.%s.urls" % plugin)), ) except: logger.debug ("Plugin %s does not provides urls" % plugin)
Where my utils.py is the — (Read more)