I have two databases configured in settings.py, the default one and another called "local_mysql".
I want to create a model such that when I do python manage.py syncdb it is only populated in the local_mysql database. How is this possible?
I couldn't find much searching around.
You need to implement a database router, as detailed in the documentation:
To define your router, its just a class with some methods:
Put this class in a file called
routers.pyin the same location asviews.pyfor your app, for which you want to redirect the database.Then, in
settings.py, add the following: