-
-
Save gitllermopalafox/88096217f9b633ad8be1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf import settings | |
import re | |
class SubdominiosMiddleware: | |
def process_request(self, request): | |
request.domain = request.META['HTTP_HOST'] | |
request.subdomain = '' | |
parts = request.domain.split('.') | |
if len(parts) == 3 or (re.match("^localhost", parts[-1]) and len(parts) == 2): | |
request.subdomain = parts[0] | |
request.domain = '.'.join(parts[1:]) | |
# set the right urlconf | |
if request.subdomain and request.subdomain != 'www' : | |
request.urlconf = 'Casher.store.urls' #Ruta de tu URL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment