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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:03:08+00:00 2026-06-05T06:03:08+00:00

I have a website which is using two databases. I have a router set

  • 0

I have a website which is using two databases. I have a router set up as stated in the django documentation. The routing works fine when I use the runserver. However I wasn’t able to test it using LiveServerTestCase. The queryset is empty.
I assume that the fixtures are not loaded correctly into the second database.
The test works if I remove the database router (and therefore only use one db).

Here is my Router config:

class ScreenerRouter(object):
    def db_for_read(self, model, **hints):
        if model._meta.app_label == 'screener':
            return 'filemaker'
        return None

    def db_for_write(self, model, **hints):
        if model._meta.app_label == 'screener':
            return 'filemaker'
        return None

    def allow_relation(self, obj1, obj2, **hints):
        if obj1._meta.app_label == 'screener' or obj2._meta.app_label == 'screener':
            return True
        return None

    def allow_syncdb(self, db, model):
        if db == 'filemaker':
            return model._meta.app_label == 'screener'
        elif model._meta.app_label == 'screener':
            return False
        return None

I have set multi_db = True in the TestCase.

Another issue was that dumpdata –database=filemaker screener.ScreenerRouter returns an empty array, even though there are entries in the DB. I can even edit them in the DjangoAdmin. I had to copy the data to the default DB and dump it from there.

  • 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-06-05T06:03:09+00:00Added an answer on June 5, 2026 at 6:03 am

    I figured out the problem. I had multiple apps that needed access to the ‘filemaker’ database and each one had its own router.
    The routers were processed in order. But the allow_syncdb method of the first router already returned a value which prevented syncdb and dumpdata for all other apps.

    The solution was to write one MasterRouter for the filemaker db and put all apps in there.
    As in:

    if obj1._meta.app_label in ['app1', 'app2']:
        return 'filemaker'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Twitterizer which works great. I have a website (.NET 4, C#)
I have Drupal 6 website which is using FCK Editor as HTML editor. It
I have a website which works with PHP on the server side. Users access
I am using LINQ to SQL for my website to access two databases. The
I have a ASP.NET website which contains a Google Map. I am using the
I have a web site with an API which publishes the information using JSON.
I have a website which sells a product to the user (downloadable). I am
I have a website which fetches information from RSS feeds periodically (well, currently manually,
I have a website which allows secure (ssl) file uploads and download. The site
I have a website which uses Spring Security. I have realized that when I

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.