book
book

Reputation: 253

Where to put routers.py for database routing in a Django project

I am trying to put a routers.py file into a Django project so that my application will use two different databases: one for my external data, the other for the pages in my newly-installed Wagtail CMS.

Where in the file system should I put routers.py? The file system currently looks like this:

projectname/
    projectname/
        settings.py
        urls.py
        wsgi.py
    app1/
        admin.py
        apps.py
        models.py
        views.py
    app2/
        admin.py
        apps.py
        models.py
        views.py
    somedataloader.py
    requirements.txt
    logfile

Upvotes: 2

Views: 2028

Answers (1)

xnx
xnx

Reputation: 25518

I put mine in projectname/projectname/, parallel with settings.py, since I see it as a kind of setting. But you refer to it by its Python module path in DATABASE_ROUTERS so you could put it somewhere else if you prefer.

Upvotes: 4

Related Questions