Thursday, December 30, 2021

Re: Automatic subdomain for each user

Thank you @Tim.  Django subdomains looks promising but it's outdated. It uses codes and imports of django< v2  I have checked django-hosts but it looks as if it can be used  for only predefined list of subdomains. Please help clarify this doubt.

Thank you for your time

On Thursday, December 30, 2021 at 1:10:17 AM UTC+1 Tim Chase wrote:
On 2021-12-29 15:02, Sherif Adigun wrote:
> I am faced with a requirement where each user is required to use
> the application under his own subdomain. Whenever a user registers,
> he gets and he can add staff, manage reports,
> etc under his subdomain.
> What is the best approach to you can suggest please?

Generally this requires

1) configuring your DNS to allow for wildcard domains so that
* points at your web server, usually looking something like

* 3600 IN A

2) setting up your HTTPS certificates. This could be

- involve an ACME-aware Django route (I'm not sure if such a beast

- configuring an ACME client like certbot to update your
DNS records so that Let's Encrypt can verify that you own the
domain and then grant your a wildcard cert

- use a different CA to obtain a wildcard cert

2b) if you used a more manual method, put the certs in the
appropriate place for your web-server to pick them up

3) configure your web-server front-end/proxy (usually nginx or
Apache, but there are others) to handle the wildcard domains and pass
them through to your Django app or WSGI server or what have you. Make
sure the domain information is passed through in the HTTP_HOST header

4) use django-subdomains[1] (or maybe django-hosts[2]) middleware to
extract the intended host-name from the HTTP_HOST header and possibly
make the route reversable so that .reverse() works

5) check your views so that they make use of the HTTP_HOST
information to filter for user-specific information




You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

No comments:

Post a Comment