code: def request_get_next(request, default_next):
      
      next_url = request.POST.get('next')\
          or request.GET.get('next')\
          or request.META.get('HTTP_REFERER')\
          or default_next
      return next_url
docs: get next url form request
  
      order: POST.next GET.next HTTP_REFERER, default_next