def backurl(request, default='/'):
    """
    Return previous url from user's browser history using Referer
    header or ``default`` as fallback value.
    """

    return request.META.get('HTTP_REFERER', None) or default