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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:16:20+00:00 2026-05-15T14:16:20+00:00

Hi i am using django 1.2 .I my case i have few models which

  • 0

Hi i am using django 1.2 .I my case i have few models which are present in one db and others on second db.I have changed my settings.py file with the two database details

But when i run the server it says relation not exist.

How can i tell that for this model refer ‘a’ database and for others refer ‘b’ database.

#models.py

### this class is in a database #####


class Test(models.Model):
   id=models.AutoField(primary_key=True)
   ...
   ...
   ...
   ...
   class Meta:
      app_label=ugettext('Test')
      db_table='testing'
      verbose_name=ugettext_lazy('Testing 1,2')
   def __unicode__(self):
       return self.name


 ### this class is in b database #####


 class Test2(modes.Model):
    id=models.AutoField(primary_key=True)
    name=models.CharField(max_length=200)
    ...
    ....
    ....
    class Meta:
      app_label=ugettext('Test')
      db_table='testing2'
      verbose_name=ugettext_lazy('1,2')
    def __unicode__(self):
       return self.name

  # settings.py
   DATABASES= {  'default': {
          'NAME': 'a',
          'ENGINE': 'django.db.backends.postgresql_psycopg2',
          'USER': 'asdf',
          'PASSWORD': '123'

         },
        'users': {
          'NAME': 'b',
      'ENGINE': 'django.db.backends.postgresql_psycopg2',
      'USER': 'asdf',
      'PASSWORD': '123'

  }
 }
  • 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-15T14:16:21+00:00Added an answer on May 15, 2026 at 2:16 pm

    The django documentation has a special page for multi-db related things:

    • http://docs.djangoproject.com/en/dev/topics/db/multi-db/

    For example, a verbose way would be to specify the database to use, when a query is made, see:

    • http://docs.djangoproject.com/en/dev/topics/db/multi-db/#manually-selecting-a-database-for-a-queryset

    For a general approach, you should specify some DATABASE_ROUTERS:

    • http://docs.djangoproject.com/en/dev/topics/db/multi-db/#using-routers
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Django's built in models, how would one create a triple-join between three models.
I had the following idea: Say we have a webapp written using django which
I'm using Django-nonrel on Google App Engine and have the following models (they are
using linux commands, I have a quoted csv file which I sorted by first
I am currently using Django to construct JSON encoded objects which a retrieved using
Is it possible to have a variable number of fields using django forms? The
I have the following django model (mapped to table 'A'): class A(models.Model): name =
I am using Django ModelForms to create a form. I have my form set
I am using django with mysql (InnoDB) and have the following in my django
I'm using django-transmeta (couldn't get anything else working better with django 1.2.5) which creates

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.