Hey, I had the same error though not necessarily the same situation:

We were working with old Django 1.7, and had some HStores and used 
django_hstore lib since Django didn't natively support HStore back then. 
anyways, when migrating to 1.11 just now, I dropped the usage of 
django_hstore and used the native HStoreField. however, I imported it wrong 
in the model, and instead of:
from django.contrib.postgres.fields import HStoreField

I used:
from django.contrib.postgres.fields import hstore

and instead of:
    process_status = HStoreField(default={}, blank=True)

I used:
    process_status = hstore.HStoreField(default={}, blank=True)


it was working, but in DRF it failed with this error.

also, and maybe that was the real thing, I forgot to add 
    'django.contrib.postgres',

to my INSTALLED_APPS.

hope this helps someone as clumsy as me :)

On Monday, May 1, 2017 at 1:55:10 PM UTC+3, Змий Хорыныч wrote:
>
> Hello! 
> I have a model with HStoreField:
>
> When I try view in browser I get:
>
> AttributeError at /records/
>
> 'str' object has no attribute 'items'
>
>
> I set the breakpoint on *to_representaion* method in *DictField and I 
> see:*
>
> def to_representation(self, value):                    *self: 
> CharMappingField() value: ' "key"=>"value" '*
>     """
>     List of object instances -> List of dicts of primitive datatypes.
>     """
>     return {
>         six.text_type(key): self.child.to_representation(val) if val is not 
> None else None
>         for key, val in value.items()
>     }
>
>
> value is string, but must be dict.
>
> It is a model and serializer:
>
> class Test(models.Model):
>     attempts = HStoreField()
>
>
> class TestSerializer(serializers.ModelSerializer):
>     class Meta:
>         model = Test
>         fields = '__all__'
>
>
>
> Django version (1.11), Rest Framefork (3.6.2)
> Thanks for any help!
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to