Re: HStoreField not working

2017-06-15 Thread eyal
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.


Re: get_identity method of BaseSerializer removed in DRF 3.x version. But no documentation

2017-06-15 Thread Xavier Ordoquy
Hi,

mapping between data and instances is performed when instantiating the 
serializer.
Depending on your use case, it'll be get_object and/or your own code that 
would substitute to it.

Regards,
Xavier Ordoquy,
Linovia.

Le mercredi 14 juin 2017 18:44:09 UTC+2, Priyanka Thakur a écrit :
>
> Hi,
>
> We have overridden the "get_identity" method of BaseSerializer class in 
> DRF 2.3 version. But in DRF 3.6.2 version this method is no longer 
> supported.
>
> I tried looking for documentation, but couldn't found any.
>
> Please guide and explain how can i overide this implementation using DRF 
> 3.6.
>
> Regards,
> Priyanka
>
>

-- 
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.