Authenticated user loss an attribute that is added under user_logged_in signal.
I am using out of the box django 1.5 authentication solution. I also user_logged_in signal from django.contrib.auth.signals to add a piece of information to the logged in user to hope i can retrieve it later as follow:
-- from django.contrib.auth.signals import user_logged_in
from django.dispatch import receiver
@receiver(user_logged_in)
def add_extra_info_to_logged_in_user(sender,user,request,**kwargs):
user.extra_info = 'extra info'
print user.extra_info # I confirmed that the assignment is executed
However, i can not retrieve user.extra_info from request object as follow:
from braces.views import LoginRequiredMixin
from django.views.generic import ListView
class MyListView(LoginRequiredMixin,ListView):
def get_queryset(self):
self.request.user.extra_info # 'User' object has no attribute 'extra_info'
...
Thank you for any suggestion.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7ba8b3e3-5548-4d34-b907-7a915357058d%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home