Created
January 31, 2018 21:27
-
-
Save gilsonbp/47682fb09a15884722182a039b43cb6a to your computer and use it in GitHub Desktop.
MIDDLEWARE para set_current_tenant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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