I want to set a test cookie in my CreateView and be able to get a test result in form_valid
function (after sending a form).
Where should I put the code responsible for setting the cookie?
self.request.session.set_test_cookie()
I tried to override get_form_kwargs
and put it there, but it didn't work.
My code:
class MyView(CreateView):
def form_valid(self, form):
if not self.request.session.test_cookie_worked():
pass
else:
pass