Integrating a third-party application
First, we need to install the app into our virtual environment from PyPI:
Add the app and any of its requirements that are not there already to in settings.py
. Some will be already present; it’s up to you to check them:
'aldryn_apphooks_config',
'aldryn_boilerplates',
'aldryn_categories',
'aldryn_newsblog',
'aldryn_people',
'aldryn_reversion',
'easy_thumbnails',
'parler',
'reversion',
'sortedm2m',
'taggit',
One of the dependencies is django-filer. It provides a special feature that allows nicer image cropping. For this to work it needs it’s own thumbnail processor (easy-thumbnails) to be inserted in settings.py
:
aldryn-newsblog uses to provide multiple sets of templates and staticfiles for different css frameworks. We’re using bootstrap3 in this tutorial, so lets choose bootstrap3.:
If STATICFILES_FINDERS
is not defined in your settings.py
just copy and paste the above code.
Add the boilerplate template loader to :
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'aldryn_boilerplates.template_loaders.AppDirectoriesLoader',
'django.template.loaders.app_directories.Loader',
'django.template.loaders.eggs.Loader'
)
Add the boilerplates context processor to TEMPLATE_CONTEXT_PROCESSORS
:
Since we added a new app, we need to update our database:
The newsblog application comes with a django CMS apphook, so add a new django CMS page (let’s call it ‘Blog’), and add the blog application to it as you did for Polls in the previous tutorial step. In this case we also have to add an “Application configuration” (see the field right under the apphook field). You can configure some settings here, like the url format. It’s also possible to add multiple instances of the application, if you like. The Instance namespace should be blog
(this is used for reversing urls). Choose as the Application title and choose whatever Permalink type you prefer.
Publish the new page, and you should find the blog application at work there.
You may need to restart your server at this point.
You can add new blog posts using the admin, but also have a look at the toolbar. When you’re within the urls of the blog, you should see an extra menu item called “Blog”. You can now select “Blog” > “Add new article…” from it and add a new blog post directly from there.
In the next tutorial, we’re going to integrate our Polls app into the toolbar in, just like the blog application has been.