ip = request.META.get('REMOTE_ADDR', '') or request.META.get('HTTP_X_FORWARDED_FOR', '')
user.user_ip=ip
user.save()
class UpdateIPv4UserMeta(object):
def process_view(self, request, view_func, view_args, view_kwargs):
user = request.user
today_30min = timezone.now() + timezone.timedelta(minutes=30)
if user.is_authenticated():
if user.last_login > today_30min:
User.objects.filter(id=request.user.id).\
update(latest_ip=request.META['REMOTE_ADDR'])