百度了一下发现网上写的很多都用不了,自己写了一个,顺便可以保存进log方便查看
if 'HTTP_X_FORWARDED_FOR' in request.META.keys():
ip = request.META['HTTP_X_FORWARDED_FOR']
else:
ip = request.META['REMOTE_ADDR']
logger.info('user come , ip:%s' % ip)
百度了一下发现网上写的很多都用不了,自己写了一个,顺便可以保存进log方便查看
if 'HTTP_X_FORWARDED_FOR' in request.META.keys():
ip = request.META['HTTP_X_FORWARDED_FOR']
else:
ip = request.META['REMOTE_ADDR']
logger.info('user come , ip:%s' % ip)