[Answer]-How to make Django test client send requests to different subdomains

1👍

HTTP_HOST = 'rede.example.com'


class TestIndexView(TestCase):

    def setUp(self):
        self.url = subdomain_reverse('network_index', subdomain='rede')

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

Leave a comment