def safe_referrer(request, default):
 referrer = request.META.get('HTTP_REFERER')
 if (referrer and is_safe_url(referrer, request.get_host())):
  return referrer
 if default:
  return resolve_url(default)
 else:
  return default

def safe_referrer ( request , default ) : referrer = request . META . get ( 'HTTP_REFERER' ) if ( referrer and is_safe_url ( referrer , request . get_host ( ) ) ) : return referrer if default : return resolve_url ( default ) else : return default
takes the request and a default url .