| 129 | |
| 130 | == Test Client `login()` method changed == |
| 131 | |
| 132 | The implementation of `django.test.Client.login()` operated as a wrapper around a series of GET and POST calls accessing a nominated login URL. This approach was fragile, and tightly bound to specific templates and login mechanims. |
| 133 | |
| 134 | In [5152], we changed the implementation of the `login()` method on the test Client. `login()` now accepts a list of credentials, and exercises these credentials directly on the cookies and Session objects of a site, without accessing or using a login page. This breaks the dependence on specific template formatting, and enables the login mechanism to work with any authentication backend, and any login decorator. |
| 135 | |
| 136 | Existing uses of `login()`, e.g.: |
| 137 | {{{ |
| 138 | c = Client() |
| 139 | c.login('/path/to/login','myuser','mypassword') |
| 140 | }}} |
| 141 | should be modified to read: |
| 142 | {{{ |
| 143 | c = Client() |
| 144 | c.login(username='myuser', password='mypassword') |
| 145 | }}} |
| 146 | The keyword arguments `username` and `password` *must* be given explicitly. If an alternate authentication scheme is in use, the credentials required by that scheme can be provided instead of `username` and `password`. |