Vip*_* av 3 python django python-2.7 django-unittest
我想获得Client()Django unittests 的默认域名.我看到了一种改变默认方式的方法.但是没有找到获取默认域名的方法.
Django的测试客户端的默认域名是testserver.它在基类中是硬编码的RequestFactory.
如果要更改特定请求的域,可以将其作为kwarg传递:
self.client.get('/some-path', SERVER_NAME="anotherdomain.com")
Run Code Online (Sandbox Code Playgroud)