Data attribute (aka instant variable) added to the current logged-in user through user_logged_in signal cannot be retrieve later.
I am using out of the box django 1.5 authentication solution. After user is logged in, i use build-in user_logged_in signal from django.contrib.auth.signals to add a piece of information to the logged in user 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'
...
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/a2562cc3-c8b0-4cb4-8dac-1a6b0a4215e2%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home