Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MIDDLEWARE para set_current_tenant
from django_multitenant import *
class SetCurrentTenantFromUser(object):
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
if request.user.is_authenticated():
if hasattr(request.user, 'cliente'):
set_current_tenant(request.user.usercliente.cliente)
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