What is the proper namespacing to use when using django-hosts

Viewed 250

So I'm using django-hosts so as to have multiple domains for each app. But then I'm having an issue when trying to access the url index for each of the apps in my base.html

I'm trying to have something like this in my base.html file

<div>
    <ul>
        <li><a href="{% url 'home:index' %}">Home</a></li>
        <li><a href="{% url 'laundry:index' %}">Laundry</a></li>
        <li><a href="{% url 'tailor:index' %}">Tailor</a></li>
    </ul>
</div>

and this is my hosts.py file

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


host_patterns = patterns(
    '',
    host(r'www', 'artisan.home_urls', name='www'),
    host(r'laundry', 'artisan.laundry_urls', name='laundry'),
    host(r'tailor', 'artisan.tailor_urls', name='tailor'),
    host(r'admin', settings.ROOT_URLCONF, name='admin')

)

And I have 3 files, namely home_urls.py, laundry_urls.py, and tailor_urls.py and each of them have the same format as the one below

# home_urls.py
from django.urls import path, include

app_name = 'home'
urlpatterns = [
    path('', include('home.urls')),
]

# tailor_urls.py
from django.urls import path, include

app_name = 'tailor'
urlpatterns = [
    path('', include('tailor.urls')),
]

# laundry_urls.py
from django.urls import path, include

app_name = 'laundry'
urlpatterns = [
    path('', include('laundry.urls')),
]

But then, the problem is that only the namespacing for the home.urls is working. For the laundry and tailor urls, I keep getting a namespace error and I have no idea why. I was wondering if maybe I made a mistake in defining the hosts.py file, but I'm just not sure. Any help would be appreciated. If there's any other file you need to understand the question better, just ask. I'd be glad to provide one. Btw, I'm using Django 3.0 with Python 3.7 if that helps.

0 Answers
Related