Log in to your root or login page, grab the csrf token from the response cookie, and publish your login URL using csrftoken. This should add the csrf token to the client's cookies and allow you to view the page.
def on_start(self): """ Run on start for every Locust hatched """ r = self.client.get('') self.client.post('/accounts/login/', {'email': 'email', 'password': 'password', 'csrfmiddlewaretoken': r.cookies['csrftoken']})
source share