如何在发布带有视图消耗请求的URL时传递请求对象?
locustfile.py
def login(self):
self.__class__.user = self.__class__.user + 1
data = self.get_user_data()
csrf = self.get_csrf("/admin/login/")
resp = self.client.post("/admin/login/", data, headers={"X-CSRFToken": csrf})
if resp.status_code == 200:
self.login_success = True
else:
self.login_success = False
views.py
def start_exam(request):
try:
user = request.user