title: Django, routing between master and slave intelligently
body: <p>I have an django app that has a front end to input data, and an API to serve data. There is a master/slave setup so I am using the database router to govern write to master and read from slave.</p>
  
  <pre><code>import random
  from django.conf import settings
  
  class DBMasterSlaveRouter(object):
      def db_for_read(self, model, **hints):
          if len(settings.DB_SLAVES) &gt;= 1:
              return random.choice(settings.DB_SLAVES)
          else:
              return settings.DB_MASTER
  
      def db_for_write(self, model, **hints):
          return settings.DB_MASTER
  
      def allow_syncdb(self, db, model):
          return True
  </code></pre>
  
  <p>The problem I am having is on the front end, user input data and hit save, the page reloads and load the data from slave (this happens very quickly), since there is a lag between master and slave, the load will not reflect the latest input. I don't want to put a delay on page load. Right now I have to add <code>using('default')</code> to force to read from master on front end</p>
  
  <p>Any ideas how to fix this?</p>