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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:46:54+00:00 2026-06-04T11:46:54+00:00

Is it possible to set a different database to be used with Django Celery?

  • 0

Is it possible to set a different database to be used with Django Celery?

I have a project with multiple databases in configuration and don’t want Django Celery to use the default one.

I will be nice if I can still use django celery admin pages and read results stored in this different database 🙂

  • 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-04T11:46:56+00:00Added an answer on June 4, 2026 at 11:46 am

    It should be possible to set up a separate database for the django-celery models using Django database routers:

    https://docs.djangoproject.com/en/1.4/topics/db/multi-db/#automatic-database-routing

    I haven’t tested this specifically with django-celery, but if it doesn’t work for some reason, then it’s a bug in django-celery (or Django itself) that should be fixed.

    Your router would look something like this:

    class CeleryRouter(object):
        "Route Celery models to separate DB."
        APPS = (
            'django',  # Models from kombu.transport.django, if you're using Django as a message transport.
            'djcelery',
        )
        DB_ALIAS = 'celery'
    
        def db_for_read(self, model, **hints):
            if model._meta.app_label in self.APPS:
                return self.DB_ALIAS
            return None
    
        def db_for_write(self, model, **hints):
            if model._meta.app_label in self.APPS:
                return self.DB_ALIAS
            return None
    
        def allow_relation(self, obj1, obj2, **hints):
            if (obj1._meta.app_label in self.APPS and
                obj2._meta.app_label in self.APPS):
                return True
            return None
    
        def allow_syncdb(self, db, model):
            if db == self.DB_ALIAS:
                # Only put models from APPS into Celery table (and south for
                # migrations).
                return model._meta.app_label in self.APPS + ('south',)
            elif model._meta.app_label in self.APPS:
                # Don't put Celery models anywhere else.
                return False
            return None
    

    Then add this to your settings:

    DATABASE_ROUTERS = ['path.to.CeleryRouter']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is that possible to have model with foreign key fields on different databases? example:
Is it possible to set different texture filtering when working with sprites?
We have a piece of functionality that is used by several different applications (clients)
I'm building a MySQL database of vehicles. There are many different possible vehicle attributes
I basically have a database and an application, and what i want to do
In SQL Server (2000 or 2005) is it possible to set the database or
Is it possible in MySQL to update a single field and select multiple different
I have an application that receives information from a database, and is used to
Is it possible to use different Oracle schemas in Crystal Reports and change between
In Java SE it is possible set the cause of an exception using initCause

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.