https://django-tenant-schemas.readthedocs.io/en/latest/
El martes, 2 de octubre de 2018, 6:53:16 (UTC-6), Glen D souza escribió: > > Hi, > > I am working on a project where i am using a single django app which is > backed by different databases. > > Let me explain the use case clearly, > > I have a app say app1, and app1 data is located in two different databases > say db1 and db2 > data present in the db1 and db2 are different, lets say db1 holds the data > for state 'CA' and db2 holds the data for state 'TX'. > > I am using django admin interface for populating/viewing data through app1 > > In order to do db routing i am using sub domains, i.e if user wants to > view the data from ca he has to do ca.localhost:8000 and if he wants to > view the data for tx he has to do tx.localhost:8000 > > So from the url i am capturing the sub-domain and using it for db routing. > > Till this part my app works fine it displays the data correctly > > Now my problem is since i am using django admin to display data, when db1 > has a model x which is not present in db2 or db1 y model is different from > y model present in db2 how to dispaly such model through django admin? > > To elaborate lets say db1 has models x y and db2 has models z y1 (y and y1 > are slighlty different) > > i have corresponding django models for db1 and db2, lets say dj_model for > db1 is ca_x, ca_y and for db2 is tx_z and tx_y1 > > when user goes to ca.localhost:8000 i want my admin page to display only > the ca models i.e ca_x, ca_y > So i want to dynamically register the models in admin.py i.e > when user goes to ca.localhost:8000 i want my admin.py to look something > like this admin.site.register(ca_x, ca_y) > when user goes to tx.localhost:8000 i want my admin.py to look something > like this > admin.site.register(tx_z, tx_y1) > > Any idea how to implement this? or any other alternate approaches, right > now i can restrict the user based on permission but i want to know are > there any other methods? > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/621cbab6-55fa-4d56-bcff-b980ae2a5cb9%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

