Package a django project and its dependencies for a standalone "product" Package a django project and its dependencies for a standalone "product" django django

Package a django project and its dependencies for a standalone "product"


Use setuptools and easy_install.

Here's an introductory article.


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.


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.