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

  • Home
  • SEARCH
  • 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 4040526
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:45:50+00:00 2026-05-20T12:45:50+00:00

I have a django project that I have been using for a while, but

  • 0

I have a django project that I have been using for a while, but now I want to add some a new dataset from a second, non-django database. I have successfully configured my settings.py file to use the new database, which is called ‘mediawikidb’.

I am able to run the following command:

python manage.py inspectdb --database=mediawikidb

and I get django’s model representations for the database, but the table that I am interested in is called ‘User’. The output of inspectdb looks like this:

class User(models.Model):
user_id = models.IntegerField(primary_key=True)
user_name = models.CharField(unique=True, max_length=255)
user_real_name = models.CharField(max_length=255)
user_password = models.TextField()
user_newpassword = models.TextField()
user_newpass_time = models.CharField(max_length=14, blank=True)
user_email = models.TextField()
user_options = models.TextField()
user_touched = models.CharField(max_length=14)
user_token = models.CharField(max_length=32)
user_email_authenticated = models.CharField(max_length=14, blank=True)
user_email_token = models.CharField(max_length=32, blank=True)
user_email_token_expires = models.CharField(max_length=14, blank=True)
user_registration = models.CharField(max_length=14, blank=True)
user_editcount = models.IntegerField(null=True, blank=True)
class Meta:
    db_table = u'user'

I have been reading the docs [0] but I am pretty confused so I thought I would ask here after reading around for a while. I can’t just drop this in my model, can I? If I do it will cause issues with django for sure. How should I do this?

My other question is, how will django know which database this ‘User’ model instance relates to? I feel like I am missing something, but I can’t find anything that makes sense.

How should I set up my model to be able to access this data without messing up anything in django?

[0] http://docs.djangoproject.com/en/dev/topics/db/multi-db/

  • 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-20T12:45:51+00:00Added an answer on May 20, 2026 at 12:45 pm

    Check the following docs:

    http://docs.djangoproject.com/en/dev/topics/db/multi-db/#an-example

    They have an example of a router that indicates where to read data from and write data to. For your user model, you can configure all interactions with the mediawiki database and all other models would use your normal database.

    Just make sure to disable relations…

    class MyAppRouter(object):
    
        def _is_user_model(model):
            return str(model.__name__) == 'User' and model._meta.app_label == 'myapp'
    
        def db_for_read(self, model, **hints):
            if self._is_user_model(model):
                return 'mediawikidb'
            return None
    
        def db_for_write(self, model, **hints):
            if self._is_user_model(model):
                return 'mediawikidb'
            return None
    
        def allow_relation(self, obj1, obj2, **hints):
            if self._is_user_model(obj1) or self._is_user_model(obj2):
                return False
            return None
    
        def allow_syncdb(self, db, model):
            if db == 'mediawikidb':
                return False
            elif self._is_user_model(model):
                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 django project that I have been working on as a solo
I have a medium sized Django project, (running on AppEngine if it makes any
I have worked a bit with Django and I quite like its project/applications model
I have written a Django app that makes use of Python threading to create
When researching Google App Engine (GAE), it's clear that using Django is wildly popular
I have a Fabric task that needs to access the settings of my Django
I have a project that adds elements to an AutoCad drawing. I noticed that
I have a script that appends some rows to a table. One of the
I have a new web app that is packaged as a WAR as part
i have a input tag which is non editable, but some times i need

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.