title: Django and postgresql schemas
body: <p>I've been trying to solve this one all week, help very much appreciated.</p>
  
  <p>I have various schemas in a postgres db and I would like to be able to map to them from within the same or across different django apps.</p>
  
  <p>Some of the schemas are :</p>
  
  <p>samples</p>
  
  <p>excavation</p>
  
  <p>geophysics</p>
  
  <p>...</p>
  
  <p>I have tried the recommended way, but I'm not getting any data to display from the schemas, I can only connect to the public schema with managed tables. Here is the database connections from the settings.py file.</p>
  
  <pre><code>DATABASES = {
  
  'default': {
          'ENGINE': 'django.db.backends.postgresql_psycopg2',
          'OPTIONS': {
              'options': '-c search_path=django,public'
          },
          'NAME': 'gygaia',
          'USER': 'appuser',
          'PASSWORD': 'secret',
  },
  
  'samples': {
          'ENGINE': 'django.db.backends.postgresql_psycopg2',
          'OPTIONS': {
              'options': '-c search_path=samples,public'
          },
          'NAME': 'gygaia',
          'USER': 'appuser',
          'PASSWORD': 'secret',
  },
  }
  </code></pre>
  
  <p>source: <a href="https://www.amvtek.com/blog/posts/2014/Jun/13/accessing-multiple-postgres-schemas-from-django/" rel="noreferrer">https://www.amvtek.com/blog/posts/2014/Jun/13/accessing-multiple-postgres-schemas-from-django/</a></p>
  
  <p>In the model.py I add:</p>
  
  <pre><code>    from django.db import models
  
      # Create your models here.
      class Storage(models.Model):
          #id = models.IntegerField(default=0)
          storage_id = models.AutoField(primary_key=True)
          store_name = models.CharField(max_length=200, default='')
          address_1 = models.CharField(max_length=200, default='')
          address_2 = models.CharField(max_length=200, default='')
          region = models.CharField(max_length=200, default='')
          city = models.CharField(max_length=200, default='')
          zip = models.CharField(max_length=200, default='')
          country = models.CharField(max_length=200, default="Turkey")
          user = models.CharField(max_length=200, default="Gygaia")
          datestamp = models.DateTimeField(auto_now=True)
  
      class Meta():
          managed=False
          db_table = 'samples\".\"store'
  </code></pre>
  
  <p>I don't want to restrict schemas to users, and the database was created a few years ago so I'm not allowed to bring it all under one schema. I know there are various solutions posted on stackoverflow and other coreners of the internet, I have tried these, but I'm unable to get this to work. Any ideas how to solve thos one??</p>