Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6099011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:13:26+00:00 2026-05-23T13:13:26+00:00

I have app1 and app2, I wanna app1 use db1 and app2 use db2

  • 0

I have app1 and app2, I wanna app1 use db1 and app2 use db2

the approach I found is to using database router, a little bit complicated

I wanna know is there any simple way?

Can I just config it in settings.py

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:13:27+00:00Added an answer on May 23, 2026 at 1:13 pm

    No. The correct way is to use routers. It is very simple. See MyAppRouter in django’s documentation: https://docs.djangoproject.com/en/dev/topics/db/multi-db/#an-example:

    class MyAppRouter(object):
        """A router to control all database operations on models in
        the myapp application"""
    
        def db_for_read(self, model, **hints):
            "Point all operations on myapp models to 'other'"
            if model._meta.app_label == 'myapp':
                return 'other'
            return None
    
        def db_for_write(self, model, **hints):
            "Point all operations on myapp models to 'other'"
            if model._meta.app_label == 'myapp':
                return 'other'
            return None
    
        def allow_relation(self, obj1, obj2, **hints):
            "Allow any relation if a model in myapp is involved"
            if obj1._meta.app_label == 'myapp' or obj2._meta.app_label == 'myapp':
                return True
            return None
    
        def allow_syncdb(self, db, model):
            "Make sure the myapp app only appears on the 'other' db"
            if db == 'other':
                return model._meta.app_label == 'myapp'
            elif model._meta.app_label == 'myapp':
                return False
            return None
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program app1 which launches another application using: app2Server := CreateOleObject('app2.Server'); On
Using tomcat, I have two web-applications i.e app1 and app2. I sent url from
I currently have two apps: app1/ app2/ templates/ app1.html app2.html In app1.html, I'm including
i have three java based web application app1,app2 and app3 at production. All 3
I have my project laid out like this: Project App1 App2 My static folder
I have two webapplication at prrduction say app1 and app2. Both are on different
I have two sites that are app1 and app2. If a user requests a
i have two https web applications app1 and app2 installed on two different tomcats
I have this to work with: [ [app1, {name=>name1, path=>xyz.com/}], [app2, {name=>name2, path=>xyz.com/}], [app3,
I have application 1 and application 2. App2 needs to verify that App1 is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.