title: How to setup django-hstore with an existing app managed by south?
body: <p>I tried to use django-hstore using <a href="http://www.craigkerstiens.com/2012/06/11/schemaless-django/">this nice tutorial</a>. I added two classes to an existing app managed by South:</p>
  
  
  
  <pre class="lang-py prettyprint-override"><code>class Attribute(models.Model):
      name  = models.CharField(max_length=200, verbose_name=_("name"))
      description = models.CharField(max_length=1000, verbose_name=_("description"))
  
  class Measure(models.Model):
      attribute = models.ForeignKey(Attribute)
      data = hstore.DictionaryField(db_index=True)
      objects = hstore.HStoreManager()
  </code></pre>
  
  <p>made a <code>schemamigration --auto</code>, launched the migration and got a <code>django.db.utils.DatabaseError: type "hstore" does not exist</code>.</p>
  
  <p>Okay, the tuto seemed to be incomplete, the django-hstore <a href="https://github.com/jordanm/django-hstore/">documentation</a> told me to use the custom database backend, i added the following to my settings file:</p>
  
  
  
  <pre class="lang-py prettyprint-override"><code>DATABASES['default']['ENGINE'] = 'django_hstore.postgresql_psycopg2'
  </code></pre>
  
  <p>Then I got a <code>KeyError: 'default'</code> in <code>south/db/__init__.py", line 78</code>. At this point, the intertubes + some trial/errors pointed me to the <code>SOUTH_DATABASE_ADAPTERS</code> settings variable and I added the following to the settings:</p>
  
  
  
  <pre class="lang-py prettyprint-override"><code>SOUTH_DATABASE_ADAPTERS = {'default': 'south.db.postgresql_psycopg2'}
  </code></pre>
  
  <p>New error:</p>
  
  <pre class="lang-py prettyprint-override"><code>File ".../psycopg2/extras.py", line 769, in register_hstore
  "hstore type not found in the database. "
  psycopg2.ProgrammingError: hstore type not found in the database. please install it from your 'contrib/hstore.sql' file
  </code></pre>
  
  <p>Now this is odd because I installed the hstore extension :</p>
  
  
  
  <pre class="lang-sql prettyprint-override"><code>$ sudo -u postgres psql
  create extension hstore;
  postgres=# CREATE EXTENSION hstore;
  ERROR:  extension "hstore" already exists
  postgres=# \dx
                             List of installed extensions
    Name   | Version |   Schema   |                   Description                    
  ---------+---------+------------+--------------------------------------------------
   hstore  | 1.0     | public     | data type for storing sets of (key, value) pairs
   plpgsql | 1.0     | pg_catalog | PL/pgSQL procedural language
  (2 rows)
  postgres=# SELECT 'hstore'::regtype::oid;
    oid  
  -------
   57704
  (1 row)
  </code></pre>
  
  <p>How is this supposed to work ? I'm using Django 1.4, Postgresql 9.1.</p>