def get_ip(request):
    """
    Get the IP for the request.  use the X-Foward-For if that is set.
    """
    if request.headers.getlist("X-Forwarded-For"):
        ip = request.headers.getlist("X-Forwarded-For")[0]
    else:
        ip = request.remote_addr
    return ip