Sites Framework and Deployment

Hi - I’m working on a project to add the ability to create different frontends which share the same Django admin backend. Each frontend might have a different theme, query different models, have a different color scheme, and some might have different pages.

It seems like this would be a good use case for the Sites framework where our frontend views could render different templates, load different CSS files, or handle redirects / 404s in different ways based on the current site. On the admin side, we could create different user permissions for sites and associate models with them.

Ideally, I’d like to run multiple Sites off the same infrastructure. We’re on AWS and I can get into specifics if helpful, but the gist is that we have a load balancer which routes traffic to either Gunicorn for WSGI requests or Daphne for ASGI. We also have Celery workers and Celery beat running. We run them on servers within Docker containers. My thought was that we could handle this all by current domain. Celery jobs will all be site agnostic and if a site ID were needed, it would be passed in when queuing the job. The frontend could check the current domain to render different pages. Admin users might only have access to editing models for site 1 but whether they access the admin from the site 1 domain or the site 2 domain doesn’t matter.

One potential hiccup with that is that we already have the Sites Framework enabled to use the Sitemap Framework, and it seems that by default Django uses settings.SITE_ID for that and certain admin redirects.

How have others worked with the Sites Framework and deployed their apps in practice? Have you launched multiple web servers each with a different settings file and a different SITE_ID? Have you done it via the domain somehow? My hope is that we can accomplish it based on the request domain to save cost and complexity on the infrastructure.

I have seen some StackOverflow articles where people recommend a middleware to override settings.SITE_ID based on the request domain which maybe is an option but it also feels like there could be some unintended side effects to dynamically changing settings.