I have two apps in my Django project: a public-facing app, and a management app (not django’s built-in admin site). I want one domain name to point to the public site and another to point to the management site. (i.e. so the /index.html route, for example, would point to a view in a different app depending on the domain name.) Each app has its own URLconf and they are both being included into the main URLconf. What’s the best way to do this?
Share
There are many ways, here are some which can work for you depending on your specific constraints.
Light hack: blacklist or whitelist urls in the HTTP server configuration for each domain
Monkey patch the url router to check for the request[‘META’][‘HTTP_HOST’], because it’s definitively not available at the time urls are being configured
2 Django instances: make 2 settings files:
Make one urls script per site,
Make one settings per site as such
Run one Django instance per domain
Example settings files:
management_settings.py
public_settings.py
And run one Django server on each. Don’t forget to use the –settings switch for management commands as such: