django-subdomains config localhost
<p>I'm having trouble getting mine configured correctly.</p>

<p>Have sites enabled and site domain for "SITE_ID = 1" (db object 1 domain) set too "mysite.app"</p>

<p>I have these subdomains setup</p>

<pre><code>ROOT_URLCONF = 'mysite.urls'
SUBDOMAIN_URLCONFS = {
    None: 'frontend.urls',  # no subdomain, e.g. ``example.com``
    'www': 'frontend.urls',
    'api': 'api.urls',
}
</code></pre>

<p>etc/hosts file</p>

<pre><code>127.0.0.1       api.mysite.app
127.0.0.1       www.mysite.app
127.0.0.1       mysite.app
</code></pre>

<p>api/urls.py</p>

<pre><code>from django.conf.urls import url
from . import views

urlpatterns = [
    url(r'^$', views.index),
]
</code></pre>

<p>api/views.py</p>

<pre><code>from django.shortcuts import render
from django.http import HttpResponse

def index(request):
    return HttpResponse('API')
</code></pre>

<p>The frontend app urls and views is identical except for returning string "FRONTEND" in the HttpResponse object.</p>

<p>I can tell django-subdomains is working becuase it does go to the "frontend" app when I hit "mysite.app:8000" vs the mysite.urls as seen in the root_url_conf. It displays "FRONTEND"</p>

<p>But no matter what I do I can't get "api.mysite.app:8000" to hit the api urls file to display "API"</p>

<p>Am I missing something? I'm very new to django. Any help is appreciated.</p>

<p>Thanks.</p>

<p>Try <a href="http://api.127.0.0.1.xip.io:8000/" rel="nofollow">http://api.127.0.0.1.xip.io:8000/</a> with your dev server running at 127.0.0.1:8000. Since 127.0.0.1 isn't really a domain but an IP, it can't have subdomains. And since your hosts file redirects to 127.0.0.1 not 127.0.0.1.xip.io or similar (you don't have to do it for testing either) you won't be connected.<br>
I haven't used the library that you mentioned but from experience with self-written snippets for subdomains, I'd say this is the case.</p>

python django