title: How to set up django with a postgres database in a specific tablespace?
body: <p>What you'd expect::</p>
  
  <p>settings.py</p>
  
  <pre><code>DATABASES = {
      'default': {
          'NAME': 'db_name',
          'ENGINE': 'django.db.backends.postgresql_psycopg2',
          'USER': 'user',
          'PASSWORD': 'password',
          'HOST': 'host',
          'PORT': '5432',
          'DEFAULT_TABLESPACE': 'tablespace-name',
      }
  }
  </code></pre>
  
  <p>When I use DEFAULT_TABLESPACE, I would expect that the access will be granted using this default tablespace. But it doesn't matter what I use there. Also, if I explicitly use db_tablespace in a models Meta class, it doesn't do anything as far I can tell.</p>
  
  <p>I've tried different users as well, but even user postgres does not work. If I define db_table = "tablespace.tablename", it also does not work.</p>
  
  <p>The SQL that will work:</p>
  
  <pre><code>select count(*) from schemaname.tablename
  </code></pre>
  
  <p>I made a backup of the database and restored it locally, without creating the tablespace. It imports well and ignores the tablespace. Then it just works.</p>
  
  <p>How do I configure Django with postgres with tablespaces? Or schemaname?? Actually I don't understand anything of this, so I hope you guys can help me out.</p>
  
  <p>See also: <a href="https://docs.djangoproject.com/en/dev/topics/db/tablespaces/" rel="nofollow">https://docs.djangoproject.com/en/dev/topics/db/tablespaces/</a></p>
  
  <p>Using Django 1.3.1, postgresql 8.4, psycopg2</p>
  
  <p>Update:</p>
  
  <p>It seems that the "default schema" is not picked up when using tablespaces. I tried out some tests and here are the results using ./manage.py dbshell:</p>
  
  <p>This does work on my database without tablespaces, but does not work on the database with tablespaces:</p>
  
  <pre><code>select * from parameter;
  </code></pre>
  
  <p>This does work on both databases:</p>
  
  <pre><code>select * from tablespace.parameter;
  </code></pre>
  
  <p>Unfortunately, the option "DATABASE_SCHEMA" in the db settings does not work, neither does "db_schema" in the models Meta object. So the problem is a bit clearer now. Does anybody have a solution to this?</p>