Answer the question
In order to leave comments, you need to log in
How to forward subdomains in nginx to a Django project?
Actually, you need to send information about which particular address the user comes to. Subdomains are important so that the backend can get this information. I wanted to do it through a regular expression, but $host is empty in this case (listing all subdomains is nonsense because there are too many of them. I need to come up with something or pull it out, I don’t know
Answer the question
In order to leave comments, you need to log in
Try it through the django-hosts
hosts.py application
host_patterns = patterns('',
host(r'', settings.ROOT_URLCONF, name='www'),
host(r'(www\.)*(?P<subdomain>[0-9a-z\-]+)', 'base.urls', callback='base.callbacks.host_subdomains', name='subdomain-area'),
)
def host_subdomains(request, *args, **kwargs):
# ищим адрес сабдомена kwargs
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question