def get_client_ip(request):
    """
    X-Forwarded-For stores the client's ip when going
    through a proxy or load balancer
    Remote-Address is not as reliable as X-Forwarded-For, but if the
    server is not configured to include X-Forwarded-For header,
    thats the only option
    """
    x_forwarded_for = request.META.get("HTTP_X_FORWARDED_FOR")
    if x_forwarded_for:
        ip = x_forwarded_for.split(",")[0]
    else:
        ip = request.META.get("REMOTE_ADDR")
    return ip