0

I'm trying to set up a Django application that will accept multiple subdomain URLs. I'd like to test this locally. Since I can't nail this first step of passing in a url that has a subdomain, I can't get to the second part (figuring out if the URLconf I've set up for django-subdomains is working). The middleware checks for a subdomain, and chooses a URLconf file based on that subdomain.

I've set the following configs in /etc/hosts. When I've got the server running, and I hit these URLs, I go to the real test.com.

127.0.0.1 payments.test.com  
127.0.0.1 rampup.test.com  

(in case it matters) django-subdomains middleware settings from settings.py:

SUBDOMAIN_URLCONFS = {                                                          
    'payments': 'main.urls',                                                    
    'rampup': 'rampup.urls'                                                     
    }      

MIDDLEWARE_CLASSES = (                                                          
    'subdomains.middleware.SubdomainURLRoutingMiddleware',                      
    'django.middleware.common.CommonMiddleware',                                
    'django.contrib.sessions.middleware.SessionMiddleware',                     
    'django.middleware.csrf.CsrfViewMiddleware',                                
    'django.contrib.auth.middleware.AuthenticationMiddleware',                  
    'django.contrib.messages.middleware.MessageMiddleware',                     
    # Uncomment the next line for simple clickjacking protection:               
    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',                 
)    
Brian Dant
  • 4,029
  • 6
  • 33
  • 47
  • This is the line from [docs](http://django-subdomains.readthedocs.org/en/latest/index.html)-> Add subdomains.middleware.SubdomainURLRoutingMiddleware to your MIDDLEWARE_CLASSES in your Django settings file. If you are using django.middleware.common.CommonMiddleware, the subdomain middleware should come before CommonMiddleware. – Ashish Gupta Dec 23 '14 at 16:27
  • Remove the :8000 from your hosts file - it shouldn't be there. The hosts file deals with domain to IP mappings, not ports. – Ben Dec 23 '14 at 19:54

1 Answers1

0

Try this:

0.0.0.0 payments.test.com 
0.0.0.0 rampup.test.com
Tim Fletcher
  • 7,062
  • 1
  • 35
  • 33