2

I am trying to insert a dictionary into the htore from my python shell and I keep getting this error:

django.db.utils.ProgrammingError: function hstore(text[], integer[]) does not exist
LINE 1: ...ula" = hstore(ARRAY['function', 'formula'], ARRAY[hstore(ARR...
                                                         ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

The queryset I am using is this:

Formula.objects.get_or_create(formula={ 'function': { 'round': 0}, 'formula': {'a':  0.2 , 'b': 5, 'c': 4, 'd': 4, 'e': 1}})

Also, I have created the hstore extension and added the app django_hstore. The migration was also successful. I don't understand why it keeps failing.

Sourabh Dev
  • 743
  • 11
  • 22

1 Answers1

4

Django's HStoreField accepts only string values, hence the error: function hstore(text[], integer[]) does not exist.

Try { 'round': '0'} instead of { 'round': 0} from your example.

zenofewords
  • 442
  • 4
  • 10
  • On Django [HStoreField docs](https://docs.djangoproject.com/en/dev/ref/contrib/postgres/fields/#hstorefield) says `A field for storing mappings of strings to strings.` – slamora Jun 24 '15 at 15:52