code: def get_next(self, request):
          
          if 'next' in request.session: 
              next = request.session['next']
              del request.session['next']
          elif 'next' in request.GET:
              next = request.GET.get('next')
          elif 'next' in request.POST:
              next = request.POST.get('next')
          else:
              next = getattr(settings, 'LOGIN_REDIRECT_URL', '/')
          
          netloc = urlparse.urlparse(next)[1]
          
          if netloc and netloc != request.get_host():
              next = getattr(settings, 'LOGIN_REDIRECT_URL', '/')
  
          return next
docs: Returns a url to redirect to after the login / signup.