Search code examples
pythondjangomiddleware

Django - Configure multidomain with django.sites


I've created a project with some apps in Django:

Project
--> App1
--> App2
--> App3

I've a domain for every app:

domain1.ex domain2.ex domain3.ex

I want that, visiting domain1.ex, the App1 will be loaded. I've readed the Middleware Documentation without results. How I hould I do?


Solution

  • Create a settings file for each domain where you list the apps that should be loaded and set SITE_ID to a different number for each file (if you are using the sites framework). Then create a wsgi.py file for each domain where you set the environment variable to the corresponding settings file as DJANGO_SETTINGS_MODULE.

    You have to configure your web server to load the correct wsgi file for your domain.