Integrating a third-party application

We’ve already written our own django CMS plugins and apps, but now we want to extend our CMS with a third party app, Aldryn blog.

First, we need to install the app into our virtual environment from PyPI:

  1. pip install aldryn-blog

Add the app and any of its requirements that are not there already to INSTALLED_APPS in settings.py. Some will be already present; it’s up to you to check them:

  1. 'aldryn_blog',
  2. 'aldryn_common',
  3. 'aldryn_boilerplates',
  4. 'django_select2',
  5. 'djangocms_text_ckeditor',
  6. 'easy_thumbnails',
  7. 'filer',
  8. 'taggit',
  9. 'hvad',

One of the dependencies is easy_thumbnails. It has already switched to Django-1.7-style migrations and needs some extra configuration to work with South. In settings.py:

  1. SOUTH_MIGRATION_MODULES = {
  2. 'easy_thumbnails': 'easy_thumbnails.south_migrations',
  3. }

Configure the image thumbnail processors in settings.py:

  1. THUMBNAIL_PROCESSORS = (
  2. 'easy_thumbnails.processors.colorspace',
  3. 'easy_thumbnails.processors.autocrop',
  4. # 'easy_thumbnails.processors.scale_and_crop',
  5. 'filer.thumbnail_processors.scale_and_crop_with_subject_location',
  6. 'easy_thumbnails.processors.filters',
  7. )

Configure the templates that will be used by Aldryn Blog (if you configured django CMS to use Bootstrap templates, choose bootstrap3 instead):

  1. ALDRYN_BOILERPLATE_NAME='legacy'

Add boilerplates finder to STATICFILES_FINDERS:

  1. STATICFILES_FINDERS = [
  2. 'django.contrib.staticfiles.finders.FileSystemFinder',
  3. # important! place right before django.contrib.staticfiles.finders.AppDirectoriesFinder
  4. 'aldryn_boilerplates.staticfile_finders.AppDirectoriesFinder',
  5. 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  6. ]

Add the boilerplates loader to TEMPLATE_CONTEXT_PROCESSORS:

  1. TEMPLATE_CONTEXT_PROCESSORS = [
  2. # ...
  3. 'aldryn_boilerplates.context_processors.boilerplate',
  4. ]

Add the boilerplates context processor to TEMPLATE_CONTEXT_PROCESSORS:

  1. TEMPLATE_CONTEXT_PROCESSORS = [
  2. # ...
  3. 'aldryn_boilerplates.context_processors.boilerplate',
  4. ]

Since we added a new app, we need to update our database:

  1. python manage.py migrate

Start the server again.

The blog application comes with a django CMS apphook, so add a new django CMS page, and add the blog application to it as you did for Polls in the previous tutorial. You may need to restart your server at this point.

Publish the new page, and you should find the blog application at work there.

You can add new blog posts using the admin, but also have a look at the toolbar. You can now select “Blog” > “Add Blog Post…” from it and add a new blog post directly from there.

Try also inserting a “Latest blog entries” plugin into another page - as a good django CMS application, Aldryn Blog comes with plugins.

In the next tutorial, we’re going to integrate our Polls app into the toolbar in, just like the blog application has been.