How to Use Multiple Databases in Django Admin Interface

This was a problem I ran into recently, and here’s a simple solution to it. The Django doc’s example handles this problem by making 2 admin sites, but I wanted to handle 2 databases on1 admin dashboard.

In project_name/app_name/ we can register our objects to be on the localhost:8000/admin interface. All we need to change here is add a class MultiDBModdelAdmin from the docs, and also a class that specifies the name of our database we want for the models in this app:

Lastly, in the same file, we can register our models just as normal. Except we need to add a 2nd parameter that is using our new class OtherDatabaseAdmin .

You can explicitly check specific databases in python shell by using:

Or you can manually check inside the actual database.

After you have completed the modifications, you should be able to see, create, edit, and delete the objects to the specified database.


  1. If you’re running into issues, check to make sure your database name is correct. It is the key to your database settings in your project_name/project_name/ file:

In the code above, our database name will be otherdatabase , not blog_db .

2. Another common issue is not migrating to the specified database:

Software Engineer living in Tokyo | Linux | Cats | | |

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store