I think it makes sense to make use of Python's `get` syntax here, so you'd be able to do something like:
```
attempting_upgrade = request.session.get('attempting_upgrade', False)
if attempting_upgrade:
   ....
```