blacklwhite
blacklwhite

Reputation: 1958

Adding and Removing Django Apps without server restart?

Which changes are necessary (if possible in any way) to include/exclude a django app from a django installation without restarting the nginx server?

Especially, I want to add a new (dynamically created) application to the project without interrupting user inputs (file up- and downloads). The project does not need to access the new application, but the new application adds urls, models and databases to the existing project.

Until now I just restarted the server in idle times, but I would like to have something like:

GET
/add/<app_name>/

def add(request, app_name):
  INSTALLED_APPS.append(app_name)
  DATABASES["app-" + app_name] = { db_data }
  DATABASE_ROUTERS += ["apps." + app_name + ".router.Router",]
  …

Is it possible in any (easy) way? Are there other variables I have to modify?

Upvotes: 1

Views: 515

Answers (1)

Burhan Khalid
Burhan Khalid

Reputation: 174672

This is not possible, nor is it recommended. You need to restart the back-end server (your upstream server in nginx that is running the django process).

In addition, I am curious what you are doing when you say "dynamically created application", as this sounds like a solution looking for a problem.

Upvotes: 3

Related Questions