How to package a Django application as an addon¶
- If you simply want to add an application to a project and don’t need topackage it as an addon, see How to add a new Django application to a project instead.
Before your addon can be uploaded, the Divio Cloud must be ready to receive it.
Select Add custom addon from , or simply go straight to Add custom addon.
- Package Name: must be unique on the system. We recommend prefixing it with your own name, forexample susan-example-application.
- Name: e.g. Susan's Django Debug Toolbar
- License: select a predefined license for your addon (or leave it blank and add your own later.)
- Organisation: select an organisation if appropriate.
When you hit Create addon, the addon will be registered on the system.
Important
The package name must not contain underscores. See the note in for more information.
We need to work in the project’s directory. Create a newdirectory there with the same name as the Package Name.
Select Package Information from your addon’s menu. Download the packagingfiles, and add them to the addon. It should look something like this:
Now let’s go through the files one by one.
All the lines you need in the setup.py will be provided automatically inthe downloaded version, with the exception of the install_requires
argument:
If your addon installs an application¶
In this case, you will need to add the package to be installed to theinstall_requires
argument, for exampleinstall_requires=["example_application==1.8.3"]
.
If your addon contains an application¶
If on the other hand, for example if the application is not available on PyPI,simply add it as the inner application directory.
Add any dependencies of the application to install_requires
of setup.py
.
The init.py file¶
expects to find a version number in the addon, attutorialdjangodebug_toolbar.__version
:
For an addon that installs a package¶
We recommend providing a version number that tracks the package’s versionnumber - for example, if the addon installs version 1.8.3
, the addon’sversion
numbers should be 1.8.3.1
, 1.8.3.2
and so on.
For an addon that includes a package¶
We recommend some form of semantic versioning.
The other packaging files are simpler:
- README.rst: If you haven’t already provided a description via the Control Panel, this will beempty. If you plan to share your addon with other users, it’s important to provide a usefulREADME.
- MANIFEST.in: The default MANIFEST.in takes care of most non-Python files that an addon islikely to need the setup tools to take care of: LICENSE, plus directories for LICENSE, plusdirectories for boilerplates, templates, static and locale files.
- LICENSE: Make sure the license terms are appropriate.
Create aldryn_config.py¶
If your application requires any settings of its own, you will need to managethem in , placed at the root of your application. The general form is:
See for more details and examples.
You can use the Form
class to allow configuration via the Control Panel.
See adding form fields for user configuraionfor more information.
Provide URL configuration¶
Not all addons will have their own URL configurations that need to be includedin a project, but if they do, you can add them. See how to include an addon’s URL configuration for more details.
Add it the package name to the INSTALLED_ADDONS
in settings.py
. Thisadds it to the list of addons that the project will “watch”.
Run:
You can test that the project now works as expected.
Validate it¶
Now make sure you’re in the addons-dev/<package name>
directory.
Now, running divio addon validate
should now confirm that the addon isvalid:
Upload with .
This version of the addon will be placed into the Alpha release channel. Ifyou visit the its Versions page, you’ll be able to change the release channel.
Your addon is now available for installation into projects via the controlpanel. If you make it public, other users will be able to install it too.
You can continue uploading new versions of it, as long as each has its ownunique version number.