I highly suspect you’re sending JSON payload with a Form like content type.

JSON’s null is not a unicode.

Regards,
Xavier Ordoquy,
Linovia.

> Le 30 mai 2017 à 10:31, Priyanka Thakur <priyanka.t...@gmail.com> a écrit :
> 
> The request is a PUT request , in a test case and the response from the 
> serializer API is : 
> 
> --copy--
> {'architectureattribute': [u'Incorrect type. Expected pk value, received 
> unicode.']
> --copy--
> 
> This is the error from serializer, which is serializer ouput and not custom 
> print output.
> 
> Also, the below instance is part of serializer instance ouput. 
> 
> --copy--
> architectureattribute = PrimaryKeyRelatedField(allow_null=True, 
> queryset=Architectureattribute.objects.all(), required=False)
> --copy--
> 
> Well anyhow, though I have reduced the problem to more granular level.
> 
> QueryDict output contains output in unicode format and hence the comparison 
> while "validate_empty_values" with "None" object is failing.
> 
> I'm still struggling with 3.6.2 version and haven't tried with 3.6.3 version.
> 
> On Tuesday, 30 May 2017 12:24:36 UTC+5:30, Priyanka Thakur wrote:
> I am using Django rest 3.6.2 version .
> 
> The model class is having a ForeignKey relationship as :
> 
> class Deliverable(model.Model):
>         architectureattribute = models.ForeignKey(Architectureattribute, 
> blank=True, null=True)
> 
> 
> 
> class DeliverableSerializer(serializers.ModelSerializer):
>     class Meta:
>          model = Deliverable
>          fields = tuple([getattr(x, 'name') for x in 
> Deliverable._meta.fields])
> 
> 
> In Django Rest , the serializer object is decoded as for the foreign key as:
> 
> architectureattribute = PrimaryKeyRelatedField(allow_null=True, 
> queryset=Architectureattribute.objects.all(), required=False)
> 
> 
> With a put request i am updating only some fields and since I'm doing 
> migration, Database contains null value for the architectureattribute.
> 
> But with "null" value , serializer validation is failing. 
> 
> On debugging I found that the PrimaryKeyRelatedField is not handling the 
> "null" value, even though allow_null property is set. 
> 
> Please explain or guide, as to what I'm doing wrong here . 
> 
> 
> -- 
> 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 
> <mailto:django-rest-framework+unsubscr...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

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