Last fall, we
wrote about our development -
RedsolutionCMS . Development with the wrong name, because in fact it does not manage any content. At its core, RedsolutionCMS is a system for deploying and initially setting up web projects on Django. In this article I will try to show clearly all the advantages of our em ... RedsolutionCMS :)
Once we have a modular system, then we will add one more module to it. An example would be django-photologue - a module for publishing photo galleries to the site. Under the cut - tutorial how to write and publish the installer of your favorite (it does not have to be a photologue) module.
A few words about this module. It is a ready-made photo gallery for django. One of its advantages is:
- already finished application;
- the ability to impose water marks on photos;
- add effects, maximize images;
- already ready admin panel and all advantages arising from this;
- the ability to upload photo archives.
admin panel:

Example of the module:

')
Part 1. Manual installation
To install photologue, you need to download the module manually or install it using
pip install django_photologueThen you need to add the appropriate lines to the project.parts.py and
urls.py files :
INSTALLED_APPS += [
After the database is initialized, you need to run the following command to initialize the photologue:
python manage.py plinitHere you will be prompted to set the size of the images and their thumbnails and save these settings in the database.
Part 2. We write the installer
Now we will try to add the django-photologue module to the Redsolution CMS.
Create something like the following file tree:

django-photologue # if the module (django-photologue) is not yet published on PyPI.
Since we want urls and settings to be automatically added when the module is included in the project being created, the
settings.pyt and
urls.pyt files are written, from which the lines of code are directly extracted and added to the end of the project.sets and
py and
urls.py files , thanks to the following file:
make.py:
from redsolutioncms.make import BaseMake class Make(BaseMake): def make(self): super(Make, self).make() cms_settings.render_to('settings.py', 'settings.pyt', {}) cms_settings.render_to('urls.py', 'urls.pyt', {}) make = Make()
where
cms_settings.render_to (file_name, template_name, dictionary = None, mode = 'a +')generates content at the end of the specified project file file_name using the specified template
Parameters:
- file_name - the name of the file to be recorded
- template_name - template path
- dictionary - dictionary for template drawing
- mode - the recording mode. To overwrite, pass mode = 'w'
Note that the
settings.pyt and
urls.pyt files mentioned above contain all the information necessary for the module’s functionality, i.e. are jung patterns.
For our example, these files will be rather short:
settings.pyt:
urls.pyt:
Part 3. We publish the installer
In DESCRIPTION we place the description about the plug-in module, concisely and clearly.
MANIFEST.in - file for connecting media files to the project:
recursive-include redsolution_setup / templates * .pytsetup.py is an installer file that defines all the meta information about a package, developer, license, files, etc. in the module, as well as you need to specify the "entry point", so that the CMS, after loading the module, understands how to configure it:
setup( ... entry_points={ 'redsolutioncms': ['photologue = redsolution_setup', ], }, ... )
Now we publish the received module on PyPI. To do this, you need to register on the PyPI website, go to the project folder, in this case in redsolutioncms_photologue, and type:
python setup.py registerThen upload the project to the site:
python setup.py sdist uploadNow in Redsolution CMS on the second page when choosing a module, the photologue added by us will be displayed.
Congratulations!
