Skip to content

{% host_url %} in django tests raises error django.urls.exceptions.NoReverseMatch #132

@XJOJIX

Description

@XJOJIX

is there a way to work with host_url tags in tests?

template:

{% load hosts %}
{% host_url 'www:index' host 'www' %}

error:

django.urls.exceptions.NoReverseMatch: 'www' is not a registered namespace

test:

@override_settings(DEFAULT_HOST='sub_domain', ROOT_URLCONF='sub_domain.urls')
class IndexViewTest(TestCase):
    def setUp(self):
        self.client = Client()
        self.url = reverse_lazy('index')

    def test_index_get(self):
        response = self.client.get(self.url)
        self.assertEqual(response.status_code, 200)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions