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?
精彩评论