[Fixed]-Django + uwsgi + nginx subdomain for apps

1👍

You can use django-subdomains. From their docs:

If no subdomain argument is provided, the URL will be resolved relative to the SUBDOMAIN_URLCONFS[None] or ROOT_URLCONF, in order

>>> from subdomains.utils import reverse
>>> reverse('home')
'http://example.com/'
>>> reverse('user-profile', kwargs={'username': 'ted'})
'http://example.com/users/ted/'
>>> reverse('home', scheme='https')
'https://example.com/'

For subdomains, the URL will be resolved relative to the SUBDOMAIN_URLCONFS[subdomain] value if it exists, otherwise falling back to the ROOT_URLCONF:

>>> from subdomains.utils import reverse
>>> reverse('home', subdomain='api')
'http://api.example.com/'
>>> reverse('home', subdomain='wildcard')
'http://wildcard.example.com/'
>>> reverse('login', subdomain='wildcard')
'http://wildcard.example.com/login/'

Hope this helps.

👤Robin

Leave a comment