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 6112409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:44:31+00:00 2026-05-23T14:44:31+00:00

Simple problem – I’m using multi-db successfully with automatic routing setup as documented on

  • 0

Simple problem – I’m using multi-db successfully with automatic routing setup as documented on a legacy db (which are unmanaged). Now I want to test it. I’ve already set a testrunner to get around the managed problem and I can confirm that I am creating the databases and as expected.

My problem is that the database routing is still trying to look at the non-test database. How can I setup my routers.py file to look at the test_ database when in test mode and the non-test database any other time.

Should be simple but I’m beating my head on the wall over this one..

FWIW:

class PmCatalogRouter(object):
    """A router to control all database operations on models in
    the PmCatalog application"""

    def db_for_read(self, model, **hints):
        "Point all operations on pmCatalog models to 'catalog'"
        if model._meta.app_label == 'pmCatalog':
            return 'catalog'
        return None

    def db_for_write(self, model, **hints):
        "Point all operations on pmCatalog models to 'catalog'"
        if model._meta.app_label == 'pmCatalog':
            return 'catalog'
        return None

    def allow_syncdb(self, db, model):
        "Make sure the pmCatalog app only appears on the 'catalog' db"
        if db == 'catalog':
            return model._meta.app_label == 'pmCatalog'
        elif model._meta.app_label == 'pmCatalog':
            return False
        return None

Much appreciate the additional eyeballs on this 😉

Thanks

  • 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-23T14:44:31+00:00Added an answer on May 23, 2026 at 2:44 pm

    OK – so here’s what happened. Turns out it was completely working all along, but two separate issues caused my tests from passing. In this case I am testing the django query methods against the legacy methods. I wasn’t passing my test because the legacy methods where not looking at the test database but rather the original database. I fixed that problem and then I realized that the procedures where not getting created in the testrunner.

    Once these two problems were corrected everything magically fell together…

    HTH someone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Simple problem. I'm working on a Delphi 2007/WIN32 application which now uses MS Access
Simple problem which is causing enormous headaches. I'm using the JQuery modal plugin (jqm)
I have a very simple problem which requires a very quick and simple solution
Simple problem. I'm working on a single SQL Server database which is shared between
A simple problem. I have an ASHX handler which generates a report. Unfortunately, this
Simple problem, actually. I am trying to evaluate the possibilities of Google Apps, using
I have a simple problem that reads an Excel file (using interop) and fills
Very simple problem but one which I am unable to solve. Why would I
Simple problem that I can't figure out... How can I print a '%' character
Simple problem (I think): I want to be able to invoke a click method

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.