可以使用信号亮signal,使用方法如下:

  from django.contrib.auth.signals import user_logged_in                           
  from django.dispatch import receiver                                             
  @receiver(user_logged_in)                                                        
  def record_login_info(sender, request, user, **kwargs):                          
      pass

这样record_login_info函数就会在用户登录成功之后被调用

posted on 2013-06-14 14:11  andy071001  阅读(239)  评论(0编辑  收藏  举报