Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
XJOJIX opened this issue May 13, 2021 · 0 comments

Comments

@XJOJIX
Copy link

XJOJIX commented May 13, 2021

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant