def get_previous_url(request):
    """
    Returns URL that user was redirected from.
    """
    try:
        result = request.META.get('HTTP_REFERER')
    except (AttributeError, TypeError, ValueError):
        result = None

    return result