1👍
✅
This looks off:
if not hasattr(self.request.session['last_submitted']):
hasattr
takes two arguments and tells you if an object has a specific property name:
hasattr(...)
hasattr(object, name) -> bool
Return whether the object has an attribute with the given name.
(This is done by calling getattr(object, name) and catching exceptions.)
Do you mean to use the following?
if 'last_submitted' not in self.request.session:
👤Riaz
0👍
What I can tell you from the info you posted is that line 160 in your views.py
is triggering the error:
if not hasattr(self.request.session['last_submitted']):
Your traceback complains about a KeyError. It is basically telling you that index ‘last_submitted’ does not exist in self.request.session
.
This error is triggered basically because your code is trying to retrieve a value from an object that does not exist inside session
.
Source:stackexchange.com