2👍
✅
Store it in the session (or alternatively, cookie) if it is per request.
Edit
As an alternative if you are not using sessions or cookies, have a look at Django’s low level cache API. You can store the value in the cache and access it later.
>>> cache.set('userid', 234, 30)
Then in another context
>>> cache.get('userid')
234
👤C.B.
Source:stackexchange.com