I have the following 4 lines of code that I keep reusing in my django views. I would like a function that passes the final value (All the objects of a logged in user) to my other functions and how to call that. As a fix, I have to keep using this lines in all my functions.
sessionkey = request.session.session_key
session = Session.objects.get(session_key=sessionkey)
uid = session.get_decoded().get('_auth_user_id')
user = UserProfile.objects.get(pk=uid)
Thanks