jazzband / django-hosts

Dynamic and static host resolving for Django. Maps hostnames to URLconfs.
http://django-hosts.rtfd.org
Other
982 stars 106 forks source link

Issue with admin routing #44

Open utkbansal opened 9 years ago

utkbansal commented 9 years ago

The default admin app doesn't have a urls.py in it. So how can I use the admin site at admin.mysite.com ? What will be in the hosts.py?

utkbansal commented 9 years ago

The temporary solution that I could come up with is -

add a new file called admin_urls.py along you root urlconf

from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
    url(r'', include(admin.site.urls)),
]

and then in hosts.py

from django_hosts import patterns, host
from django.conf import settings

host_patterns = patterns(
    '',
    host(r'admin', 'subdomain.admin_urls', name='admin'),
    host(r'www', settings.ROOT_URLCONF, name='www'),
)

Is there a better way to do this?

utkbansal commented 9 years ago

Also there is no 404 showing up if I hit a non existent subdomain. Eg- If I open up a.mysite.com, it shows up what mysite.com would show up.