views:

49

answers:

2

I am using mysql database. I have many schemas with many tables. I want to create a Django admin interface for various tables in different schemas. Currently for a single schema I am using a setting like this:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'schema1',                      
        'USER': 'test',                     
        'PASSWORD': 'test',                  
        'HOST': 'example.abc.com',                     
        'PORT': '',                      
    }

After creating an app, admin interface is created for whatever models I register in the admin.py of that app for this schema. Now I want to create an other app where I register models of another schema in its admin.py. These models will belong to different schema. Now how do I create an admin interface for the second app that points to different schema?

Is it possible to create two Django projects with two different settings.py and two different admin interfaces? (So that each will point to different schema.)

I have googled a lot about this. But couldn't find any info. May be there is a simple way and I am approaching this in a wrong way. Any help is appreciated.

Thanks in advance.

A: 

This is documented well on the django doc here http://docs.djangoproject.com/en/dev/topics/db/multi-db/#exposing-multiple-databases-in-django-s-admin-interface

Meitham
Thanks. I tried this before, but I faced an issue there. While creating a new object it was referring to the default database instead of the one specified in the MultiDBAdmin. In the stacktrace I can see that the error is in django/db/transaction.py - commit_on_success method. After looking in to the source, I found that the db parameter is passed as None. So it is taking the default database. I realize this should be a separate post itself. Long story short, I concluded it was a bug and started looking for a cleaner way like one admin interface for one database...
Steve
A: 

I'm not quite sure if you mean that you want to handle different databases or just have different models registered. If you want to have different models in different admin sites, you can register multiple admin sites with different models. You can then access one site eg with '/admin' the other with '/otheradmin'. Maybe you find django-admin-tools useful to customize the display of your models/apps within the admin!

lazerscience
I want to have one admin for each database. Is it possible?
Steve