Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

make query to a different schema in django orm

Muhammad Afzaal answered on March 13, 2023 Popularity 2/10 Helpfulness 3/10

Contents


More Related Answers

  • django see sql of queryset
  • django custom query
  • write sql query in django
  • django model different schema
  • how can i get the data from a queryset in django template
  • write sql query in django
  • django database specify schema
  • create schema for table for django
  • orm query django
  • django model queries

  • make query to a different schema in django orm

    0

    from django.db import connection # Used for django tenants.

    # I am assuming you are in the main public tenant.

    connection.set_schema_to_public() # Switch to Public.

    # Here is how you switch to a different tenant.

    connection.set_schema("the-schema-name-of-your-tenant", True) # Switch to Tenant.

    # You are now in the tenant you want, therefore any call you make will be made from that db schema.

    # Therefore making this call is all you need after.

    object = TableOne.objects.first() 

    Popularity 2/10 Helpfulness 3/10 Language python
    Source: Grepper
    Link to this answer
    Share Copy Link
    Contributed on Mar 13 2023
    Muhammad Afzaal
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.