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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:36:10+00:00 2026-06-06T17:36:10+00:00

I am using django multiple DB router concepts, having multiple sites with different db’s.

  • 0

I am using django multiple DB router concepts, having multiple sites with different db’s. Base database user will login with all other sub sites.

When i try syncdb in base site its worked properly(at any time), but trying syncdb with other sites works first time only, if we try next time on-wards it throws integiry error like below

  • django.db.utils.IntegrityError: (1062, “Duplicate entry
    ’22-add_somesame’ for key ‘content_type_id'”)

Once i removed multiple DB router settings in that project means syncdb works properly(at any time).

So is this relates to multiple db router? or what else?

Please anyone advise 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-06-06T17:36:12+00:00Added an answer on June 6, 2026 at 5:36 pm

    The problem here is with the db router and django system objects. I’ve experienced the same issue with multiple DBs and routers. As I remember the problem here is with the auth.permission content types, which get mixed in between databases. The syncdb script otherwise tries to create these in all databases, and theb it creates permission content type for some object, which id is already reserved for a local model.

    I have the following

    BASE_DB_TYPES = (
     'auth.user',
     'auth.group',
     'auth.permission',
     'sessions.session',
    

    )

    and then in the db router:

    def db_for_read(self, model, **hints):
        if hasattr(model, '_meta') and str(model._meta) in BASE_DB_TYPES:
            return 'base_db' # the alias of base db that will store users
        return None # the default database, or some custom mapping
    

    EDIT:

    Also, the exception might say that you’re declaring a permission ‘add_somesame‘ for your model ‘somesame‘, while Django automatically creates add_, delete_, edit_ permissions for all objects.

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

Sidebar

Related Questions

I am building a Django site framework which will power several independent sites, all
Is it possible to run multiple Django sites on the same server using Nginx
I have a django application using multiple databases. Given an instance of a model,
In Django, I know using filter with multiple arguments gets translated into SQL AND
Am using django social-auth authentication for my app.After login to facebook or twitter from
I am using django 1.2 to create a multi site shop. I need multiple
I'm looking for a good way to install multiple completely different Django projects on
I'm using a hand built (Postgres) database with Django. With inspectdb I was able
Is it possible and correct to have multiple sites under single django project. So
I have multiple Django models that reference a model using foreign keys as such:

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.