Aldryn Addons (addon integration)¶

Aldryn Addons framework helps integrate addons and their settings intoa Django project.

Its an open-source package, andis itself an addon. The addons framework is installed by default in all DivioCloud Django projects.

Aldryn Addons configuration options¶

Addon URLs¶

A project, or an addon in it, may need to specify some URL patterns.

They could simply be added to the project’s urls.py manually. However, it’salso convenient for addons to be able to configure URLs programmatically, sothat when an addon is installed, it will also take care of setting up therelevant URL configurations.

Aldryn Addons provides a way to do this. A Divio Cloud project’s urls.pycontains:

  1. urlpatterns = [
  2. # add your own patterns here
  3. ] + aldryn_addons.urls.patterns() + i18n_patterns(
  4. # add your own i18n patterns here
  5. *aldryn_addons.urls.i18n_patterns() # MUST be the last entry!
  6. )

As well as indicated places for manually-added patterns, it callsaldryn_addons.urls.patterns() and aldryn_addons.urls.i18n_patterns().

These functions, in the urls.py of Aldryn Addons,check for and return the values in four different settings:

ADDON_URLS and ADDON_URLS_I18N¶

These are expected to be lists of URL patterns. Each addon that needs to addits own URL patterns should add them to the lists.

For example, in Aldryn django CMS:

  1. settings['ADDON_URLS'].append('aldryn_django_cms.urls')

ADDON_URLS_LAST and ADDON_URLS_I18N_LAST¶

These are not lists, and only one of each can be set in any project - it’s notpossible for two applications both to specify an ADDON_URLS_I18N_LAST forexample.

django CMS sets settings['ADDON_URLS_I18N_LAST'] = 'cms.urls' - so ina project using django CMS, no other application can use ADDON_URLS_I18N_LAST.

原文: http://docs.divio.com/en/latest/reference/addons-aldryn-addons.html