title: How to access a remote PostgreSQL database server (Read only transaction) in Django?
body: <p>I have a PostgreSQL database server which is read only transaction. I need to extract some from this database in Django. My <code>setting.py</code> file is given below:</p>
  
  <pre><code>{
    {
      DATABASES = {
        'default': {
          'ENGINE': 'django.db.backends.postgresql_psycopg2',
          'NAME': 'supercaller',
          'USER' : 'chandra_m',
          'PASSWORD' : 'XXXXX',
          'HOST': 'xx.xxx.xxx.xxx',
          'PORT': '5432',
        }
      }
    }
  }
  </code></pre>
  
  <p>I am running the server with <code>python manage.py runserver</code>. I am getting following error</p>
  
  <pre><code>  System check identified no issues (0 silenced).
    Unhandled exception in thread started by &lt;function wrapper at 0x1aa9230&gt;
    Traceback (most recent call last):
     File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site-   
     packages/django/utils/autoreload.py", line 222, in wrapper
     fn(*args, **kwargs)
    File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site - 
    packages/django/core/management/commands/runserver.py", line 107, in inner_run
      self.check_migrations()
    File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site-
    packages/django/core/management/commands/runserver.py", line 159, in check_migrations
      executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
    File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site-
    packages/django/db/migrations/executor.py", line 17, in __init__
      self.loader = MigrationLoader(self.connection)
    File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site-
    packages/django/db/migrations/loader.py", line 48, in __init__
      self.build_graph()
    File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site-
    packages/django/db/migrations/loader.py", line 179, in build_graph
      self.applied_migrations = recorder.applied_migrations()
    File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site-
    packages/django/db/migrations/recorder.py", line 59, in applied_migrations
      self.ensure_schema()
    File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site-
    packages/django/db/migrations/recorder.py", line 53, in ensure_schema
      editor.create_model(self.Migration)
    File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site-
    packages/django/db/backends/schema.py", line 270, in create_model
      self.execute(sql, params)
    File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site-
    packages/django/db/backends/schema.py", line 98, in execute
      cursor.execute(sql, params)
    File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site- 
    packages/django/db/backends/utils.py", line 81, in execute
      return super(CursorDebugWrapper, self).execute(sql, params)
    File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site-
    packages/django/db/backends/utils.py", line 65, in execute
      return self.cursor.execute(sql, params)
    File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site- 
    packages/django/db/utils.py", line 94, in __exit__
      six.reraise(dj_exc_type, dj_exc_value, traceback)
    File "/home/birendra/knowlarity/chandra/NodetoDjango/venv/local/lib/python2.7/site-
    packages/django/db/backends/utils.py", line 65, in execute
      return self.cursor.execute(sql, params)
    django.db.utils.InternalError: cannot execute CREATE TABLE in a read-only transaction
  </code></pre>
  
  <p>However, I am able to access this database server through a shell prompt with</p>
  
  <pre><code>psql -h 46.xxx.xxx.52 supercaller chandra_m
  </code></pre>
  
  <p>How to fix the errors?</p>