我正在使用开箱即用的 django 1.5 身份验证解决方案。经过身份验证后,我想使用来自 django.contrib.auth.signals 的 user_logged_in 信号向用户添加“post_login_info”
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 = 'my post login information'
但是,我稍后无法从请求对象中检索 user.post_login_info,如下所示:
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'
...
谢谢你的任何建议。