开发者

Django - How can I save users ipaddress in admin log?

I am using django auth module.Now,when user logs in I want to record users ipaddress in the ad开发者_JAVA技巧min_log table.How can I do this?

thanks


Create a middleware, that will be called after AuthenticationMiddleware is called (it must be spcified after the latter in settings.py). In this middleware retrieve ip address from HttpRequest.META attribute (it would be probably request.META['REMOTE_ADDR']) and add this information to the admin_log table. But is admin_log exactly the place where you would like to store this information?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜