How to add a post-login information to an authenticated user?

61 views
Skip to first unread message

Khanh Tran

unread,
Oct 18, 2013, 3:17:50 PM10/18/13
to django...@googlegroups.com
I am using out of the box django 1.5 authentication solution. After authenticated, i want to add a 'post_login_info' to the user using user_logged_in signal from django.contrib.auth.signals

from django.contrib.auth.signals import user_logged_in
from django.dispatch import receiver

@receiver(user_logged_in)    
def post_login_action(sender,user,request,**kwargs):
    user.post_login_info = 'post login info'
    


However, i can not retrieve user.post_login_info from request object later as follow:

from braces.views import LoginRequiredMixin
from django.views.generic import ListView

class MyListView(LoginRequiredMixin,ListView):
    def get_queryset(self):
        self.request.user.post_login_info  # Attribute Error: 'User' object has no attribute 'post_login_info'
        ...

Thank you for any suggestion. 

Khanh Tran

unread,
Oct 18, 2013, 4:28:42 PM10/18/13
to django...@googlegroups.com
Even though i have not directly answered my question, i found out that session storage is an alternative solution.
Reply all
Reply to author
Forward
0 new messages