Reputation: 3002
I have a simple model:
class TestModel(models.Model):
test_store = HStoreField()
I edited the migration for this model per the HStoreField docs.
I have no trouble creating an object with test data {"foo": "bar"}
, and in the Admin, the field for test_store
displays the value as such, but when I try to save it with the Admin, I get the following error:
TypeError: expected string or buffer
Why?
I'm using Django 1.8.3 and Python 2.7.9
Hint: It seems like it's passing the data as {u'foo': u'bar'}
and running into issues with the JSONDecoder:
def decode(self, s, _w=WHITESPACE.match):
"""Return the Python representation of ``s`` (a ``str`` or ``unicode``
instance containing a JSON document)
"""
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
...
end = _w(s, end).end()
if end != len(s):
raise ValueError(errmsg("Extra data", s, end, len(s)))
return obj
def raw_decode(self, s, idx=0):
Upvotes: 0
Views: 274
Reputation: 344
This error occurs due to the fact that in json.load()
passed a variable of type dict()
. This bug is fixed in next django release.
I apologize for my english, i used google translate.
Upvotes: 4