Skip to content

Instantly share code, notes, and snippets.

@gilsonbp
Created December 26, 2018 17:32
Show Gist options
  • Save gilsonbp/559f5a0b24743bad020b2bc80e04c889 to your computer and use it in GitHub Desktop.
Save gilsonbp/559f5a0b24743bad020b2bc80e04c889 to your computer and use it in GitHub Desktop.
Middleware que faz um teste específico então redireciona para uma rota
from django.shortcuts import redirect
class RedirectHome(object):
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
if True: # Faz o teste ante de redirecionar
return redirect('site:home')
response = self.get_response(request)
return response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment