Code

Ticket #15179: requestfactory_for_login.diff

File requestfactory_for_login.diff, 602 bytes (added by Ciantic, 3 years ago)

Client.login to use RequestFactory

Line 
1diff --git a/django/test/client.py b/django/test/client.py
2index 24fe627..068f566 100644
3--- a/django/test/client.py
4+++ b/django/test/client.py
5@@ -504,7 +504,8 @@ class Client(RequestFactory):
6             engine = import_module(settings.SESSION_ENGINE)
7 
8             # Create a fake request to store login details.
9-            request = HttpRequest()
10+            # Notice that we cannot use super get since it returns response
11+            request = RequestFactory(**self.defaults).post("/login/")
12             if self.session:
13                 request.session = self.session
14             else: