[Django]-Package a django project and its dependencies for a standalone "product"


Yes, you can package it. Django may not be the easiest to do this with, but the principles are the same for other frameworks. You need to make an installer that installs everything you need. And that installer needs to be different for different platforms. such as Windows, Ubuntu, OS X etc. That also means that the answer is significantly different for each platform, and only half of the answer is dependning on Django. 🙁

This kinda sucks, but that’s life, currently. There is no nice platform independent way to install software for end users.


Use setuptools and easy_install.

Here’s an introductory article.



I also haven’t found the perfect solution for this yet.

My current approach is to provide a docker image because that’s really easy to use for everyone. This includes an alpine base image because it’s tiny and python + django and the app itself. You can also include a webserver like nginx and an app server like uwsgi or gunicorn and expose a port for it.

So in the end your user would just run the container and access the web app under http://localhost:9000/ or something like this.
This is really handy and also my preferred way of trying out some app I’ve found.

The “proper” way would be do build a package for every OS and distribution you are targeting and a simple zip bundle so people can also install the app manually.

To build the packages I suggest using fpm. It takes most of the pain of doing the packaging with their native tools away. The packages would then depend on a proper application server like uwsgi or gunicorn.

So in the end you could then install it like apt install your-package and it would depend on python-django, uwsgi etc.

For the location and where to put all the files in the package every distribution has their own way of doing it. I prefer putting everything under /usr/share/webapps/myapp/ and having the config under /etc/myapp/config.py or something like that.

For Windows and macOS there are solutions like PyInstaller. I haven’t used it yet for a django app but it should do the job. You should include a app server like uwsgi in there too.

In generel you don’t want to run the django dev server in a production environment. So keep that in mind when packaging.

I hope that helps a bit.



There are several ways of doing this. I think you are looking more for build tools (which includes packaging) rather than just a Python solution. Here are a couple that I’ve used in the past:

zc.buildout: Used to build and deploy Python modules and applications, but is also able to work with other languages with a little massaging. Easy to use (for a build tool).

make: The software build classic. Works with practically all languages but a little archaic and hard to learn for a first timer.


The new snap package manager for Linux should suit the task perfectly. It provides all the solutions that were quite a pain for Python apps so far (dependencies, interpreter etc) and at the same time avoiding the complexity of Docker.


These days Docker is probably a good answer

User needs to install Docker first, but it runs on Windows and OSX as well as Linux.

Your Dockerfile takes care of installing all the dependencies and then runs the devserver (or you could even run a proper webserver in the container)

Leave a comment