jazzband/django-hosts

Blank or www catches url with subdomain

Opened this issue · 1 comments

If I have the following hosts.py:-

host_patterns = patterns(
    '',

    host(
        r'|www',
        'config.urls.cc',
        name='main'
    ),

host(
        r'manage',
        'config.urls.manage',
        name='manage'
    ),

    host(
        r'(?P<subdomain>\w+)',
        settings.ROOT_URLCONF,
        name='other'
    ),
)

and I go to example.com or www.example.com, I'd expect it to match the 1st host, which it does.

But if I go to manage.example.com, I'd expect it to match the 2nd in the list - or if I go to somethingelse.example.com, I'd expect it to match the last host. However, both of these urls are matched by the 1st host (the cc one).

Any ideas?

I fix it with

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

host_patterns = patterns('',
    host(r'(www.example.com|example.com)', settings.ROOT_URLCONF, name='www'),
    host(r'(?P<domain>\w+)', 'apps.pages.urls', name='pages'),
)