2👍
Did you follow the rest of the directions? You need to add the output from inspectdb
to a models.py
file in one of your apps, then add that app to your INSTALLED_APPS
.
Try the following:
1) Create an app
If you don’t have an app you want to put the output from inspectdb
into, just run python manage.py startapp legacy
. This would create an app named legacy
that you could sync up your existing database through.
2) Add inspectdb output to your app’s models file
In the models.py
file of your chosen app, paste the output from the inspectdb
command. The easiest way to do this is probably to run python manage.py inspectdb > models.py
. This will create a file called models.py
in the same directory that has manage.py
and your app directories. Copy the output from that file into the models.py
file in your app, i.e. in legacy/models.py
.
3) Add your app to INSTALLED_APPS
In your settings.py
, add your app to INSTALLED_APPS
. In this example, you’d want to add 'legacy',
to INSTALLED_APPS
.
4) Run syncdb
Run python manage.py syncdb
to make sure all required tables are included. It looks like you already have those based on the output pasted above, but it won’t hurt to run it again.
0👍
I found the answer, and it’s an obvious one: Database routing. You need to create a routers.py
file and add this to your settings.py
:
DATABASE_ROUTERS = ['myapp1.routers.name-of-your-routers.py-class',
'myapp2.routers.name-of-your-routers.py-class']
DATABASE_APPS_MAPPING = {'myapp1': 'mydb1',
'myapp2':'mydb2'}
Djangosnippets has the routers.py
file: https://djangosnippets.org/snippets/2687/
You need do add an attribute called in_db = 'desired-db'
in the Meta class of every class in your models.py
.
- [Answered ]-Django – reload only body page using block not refresh whole page
- [Answered ]-Edit form in Django 1.6