title: How to add database routers to a Django project
body: <p>I'm following the instructions on how to handle multiple databases within one Django project from here <a href="https://docs.djangoproject.com/en/2.1/topics/db/multi-db/" rel="noreferrer">topics/db/multi-db</a></p>
  
  <p>I've created the two routers required.
  They are saved as ./database_routers/discourse.py and ./database_routers/wordpress.py</p>
  
  <p>The contents of ./database_routers/discourse.py is</p>
  
  <pre><code>class DiscourseRouter:
      """
      A router to control all database operations on models in the
      discourse application.
      """
      def db_for_read(self, model, **hints):
          """
          Attempts to read discourse models go to discourse.
          """
          if model._meta.app_label == 'discourse':
              return 'discourse'
          return None
  
      def db_for_write(self, model, **hints):
          """
          Attempts to write discourse models go to discourse.
          """
          if model._meta.app_label == 'discourse':
              return 'discourse'
          return None
  
      def allow_relation(self, obj1, obj2, **hints):
          """
          Allow relations if a model in the discourse app is involved.
          """
          if obj1._meta.app_label == 'discourse' or \
             obj2._meta.app_label == 'discourse':
             return True
          return None
  
      def allow_migrate(self, db, app_label, model_name=None, **hints):
          """
          Make sure the discourse app only appears in the 'discourse'
          database.
          """
          if app_label == 'discourse':
              return db == 'discourse'
          return None
  </code></pre>
  
  <p>The contents of ./database_routers/wordpress.py is</p>
  
  <pre><code>class WordpressRouter:
      """
      A router to control all database operations on models in the
      wordpress application.
      """
      def db_for_read(self, model, **hints):
          """
          Attempts to read wordpress models go to wordpress.
          """
          if model._meta.app_label == 'wordpress':
              return 'wordpress'
          return None
  
      def db_for_write(self, model, **hints):
          """
          Attempts to write wordpress models go to wordpress.
          """
          if model._meta.app_label == 'wordpress':
              return 'wordpress'
          return None
  
      def allow_relation(self, obj1, obj2, **hints):
          """
          Allow relations if a model in the wordpress app is involved.
          """
          if obj1._meta.app_label == 'wordpress' or \
             obj2._meta.app_label == 'wordpress':
             return True
          return None
  
      def allow_migrate(self, db, app_label, model_name=None, **hints):
          """
          Make sure the wordpress app only appears in the 'wordpress'
          database.
          """
          if app_label == 'wordpress':
              return db == 'wordpress'
          return None
  </code></pre>
  
  <p>I created an empty <code>./database_routers/__init__.py</code> file</p>
  
  <p>The database router settings in api/settings I've set to</p>
  
  <pre><code>DATABASE_ROUTERS = ['database_routers.DiscourseRouter', 'database_routers.WordpressRouter']
  </code></pre>
  
  <p>When I attempt to look at the project using shell plus I with</p>
  
  <pre><code> ./manage.py shell_plus
  </code></pre>
  
  <p>I get </p>
  
  <pre><code>ImportError: Module "database_routers" does not define a "DiscourseRouter" attribute/class
  </code></pre>
  
  <p>How do you add database routers to a Django project such that python recognises the path directory_name.ClassName?</p>