Skip to content

Instantly share code, notes, and snippets.

@bertini36
Last active December 31, 2015 18:46
Show Gist options
  • Save bertini36/05f4129ce3fc549450bd to your computer and use it in GitHub Desktop.
Save bertini36/05f4129ce3fc549450bd to your computer and use it in GitHub Desktop.
from django.db import connection
from customers.models import Client
from contacts.models import Contact
tenant = Client.objects.get(name='Tenant 1')
connection.set_tenant(tenant)
# Ahora estamos conectados al Tenant 1.
# Todas las consultas a BD se realizarán sobre el esquema tenant1
contacts = Contact.objects.all()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment