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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:55:11+00:00 2026-05-26T12:55:11+00:00

Django’s ORM supports querying from a specific database (when multiple are defined in your

  • 0

Django’s ORM supports querying from a specific database (when multiple are defined in your project) via the .using() function for filter-based operations.

e.g. MyModel.objects.filter(name='Bob').using('my_non_default_database')

How would you do the equivalent when creating new records, via the class MyModel() or shortcut like get_or_create()?

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

    using is a method on the MyModel.objects manager, so you can do

    MyModel.objects.using('my_non_default_database').get_or_create(name="Bob")
    

    If you have a MyModel instance, you can use the using keyword to specify the database to save to. The django docs point out some gotchas.

    my_model = MyModel(name="Bob")
    my_model.save(using='my_non_default_database')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Django-Social in its feature list claims that it supports associating multiple authentication providers to
Django can make use of multiple database engines at the same time. My problem
Django view points to a function, which can be a problem if you want
Django (1.2 beta) will reset the database(s) between every test that runs, meaning each
Django book and Real World Haskell are using some similarly-looking web publishing platforms (with
Django, What's the best ,fastest way to get only first and last element from
Django's ORM (version 1.2.3) does not preserve identity when following foreign keys back and
Django when i send the following string from an ajax submit i get the
Django has the Flatpages app, which lets site admins change content on specific pages
Django is sending the pre/post_delete signals if you are using the queryset.delete() method, but

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.