Pranav Garg
Pranav Garg

Reputation: 613

Tying a model to a specific database alias

I have defined two databases in my settings.py with default, cas.

In my accounts application models.py I have created two clases UserProfile and Users.

I want to tie UserProfile table to default and Users to cas db setting:

so for e.g. when I do a syncdb using the following command

python manage.py syncdb --database=cas

it should create only the users table in CAS and not the UserProfile table too.

Is there a way I can achieve this?

Upvotes: 2

Views: 773

Answers (1)

vdboor
vdboor

Reputation: 22526

Take a look at the Database routing features of Django 1.2. You'll likely find what you need:

http://docs.djangoproject.com/en/dev/topics/db/multi-db/#automatic-database-routing

Upvotes: 2

Related Questions