Skip to main content

How to add a Django application to an Aldryn application

This article applies to applications using the Aldryn framework only.

info

This article assumes you are already familiar with the steps involved. For a full walk-through, see the Make changes and deploy them section of the developer tutorial.

If an addon has not yet been created for the application you require, you have two options:

Make the package available to the application

You can do this in one of two ways:

Configure the application

Configure settings

Add the names of any required applications to the INSTALLED_APPS.extend() method in settings.py.

Other key settings (such as MIDDLEWARE_CLASSES) will already be defined in settings, so don't simply declare them (e.g. MIDDLEWARE_CLASSES =[...]). If you do this, you will overwrite existing settings. Instead, use for example MIDDLEWARE_CLASSES.extend([...]).

Ordering of settings lists

The ordering of applications, middleware and other settings lists can matter, in which case you may need to make sure you add the item at the start, end or particular position in the list.

If for example your DebugToolbarMiddleware should be directly after the GZipMiddleware, you could do:

MIDDLEWARE_CLASSES.insert(
MIDDLEWARE_CLASSES.index("django.middleware.gzip.GZipMiddleware") + 1,
"debug_toolbar.middleware.DebugToolbarMiddleware"
)

Configure URLs

Edit the urls.py of the application in the usual way, to include the urls.py of your application, for example:

urlpatterns = [
url(r'^polls/', include('polls.urls', namespace='polls')),
] + aldryn_addons.urls.patterns() + i18n_patterns(
# add your own i18n patterns here
*aldryn_addons.urls.i18n_patterns() # MUST be the last entry!
)

Alternatively, add the URL configuration to be included via one of the addon URLs settings, in your application's settings.py.

Migrate the database

If the application has migrations, you should test them locally. Run:

docker compose run web python manage.py migrate

Deploy the application

Push your changes

git add <changed or added files>
git commit -m "<message describing what you did>"
git push origin develop

Deploy the Test server

divio app deploy test