I recently downloaded the django_messages application (a private user for messaging with the user's django application) and added it to my django project.
settings.py
INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', 'mydjangoapp.mydjangoappdb', 'tastypie', 'gunicorn', 'south', 'relationships', 'pyapns', 'django_messages',
The app works great and works great with Django. However, for features such as messaging, the database can be quite large. I decided to create a special database to store all the django_messages data.
settings.py
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'django_db', 'USER': 'django_login', 'PASSWORD': 'xxxx', 'HOST': '', 'PORT': '', }, 'message_db': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'django_messagedb', 'USER': 'django_login', 'PASSWORD': 'xxxx', 'HOST': 'XX.XXX.XX.XXX', 'PORT': '5432', } DATABASE_ROUTERS = ['mydjangoapp.messagerouter.MessageRouter']
And just for clarification, here is my messagerouter.py
class MessageRouter(object): """ A custom router written by Riegie to control all database operations on models in the django_messages application """ def db_for_read(self, model, **hints): """ Attempts to read django_messages models go to message_db. """ if model._meta.app_label == 'django_messages': return 'message_db' return None def db_for_write(self, model, **hints): """ Attempts to write django_messages models to go to message_db. """ if model._meta.app_label == 'django_messages': return 'message_db' return None def allow_relation(self, obj1, obj2, **hints): """ Allow relations if a model in the django_messages. """ if obj1._meta.app_label == 'django_messages' or \ obj2._meta.app_label == 'django_messages': return True return None def allow_syncdb(self, db, model): """ Make sure the django_messages app only appears in the 'message_db" database. """ if db == 'message_db': return model._meta.app_label == 'django_messages' elif model._meta.app_label == 'django_messages': return False return None
As you can see, I have two databases: one on the local machine running Django, and the other database on the remote machine. Out of the box, after installation, django_messages naturally creates tables in the default database. However, I would like it to create tables only in the message_db database.
I looked through the Multi-db Setup Django Documentation, but it details the configuration of the Master / Slave. I used the Auth Router example and created messagerouter.py. Everything is synchronized and I get no errors.

However, when I check the remote database, the table is not there! Why is this? Is this because it is not possible for a Django user to have a relation of a remote foreign key to a table?
UPDATE
Therefore, I was able to synchronize the Django_messages application with another database using the following command: ./manage.py syncdb --database = message_db . Excellent. However, when I access the application from the Django admin page, I get the following error:
DatabaseError at /admin/django_messages/message/ relation "django_messages_message" does not exist LINE 1: SELECT COUNT(*) FROM "django_messages_message"
I find this error odd because I see a table on another server through pgadmin III. So the synchronization worked correctly, but now it seems that Django cannot recognize this table. Am I something wrong with my messagerouter.py maybe?