Hi,

ok, understood that. But at some point python would need to call that 
property/method whatever. And if it does not exist, python would thrown an 
error.
So why this error is not raised?

Regards
Andi

Am Donnerstag, 15. November 2018 18:08:36 UTC+1 schrieb Xavier Ordoquy:
>
> Hi,
>
> There are no errors because the value gets map to the instance’s « abc ».
> It could be a property with setters / getters that process the value and 
> fill some of the model’s field (or the other way around). For example, you 
> could have a write only property « password » that takes a password, 
> hash/salt it and sets it to the hashed_password field. It could also be 
> some reporting computed live for a read only property.
>
> Regards,
> Xavier.
>
>
> Le 15 nov. 2018 à 16:43, andreashanauska via Django REST framework <
> django-res...@googlegroups.com <javascript:>> a écrit :
>
> Hi,
>
> recently i deployed an API using the following serializers:
>
> class SimpleMotorTypeSerializer(serializers.ModelSerializer):
>
>     class Meta:
>         model = MotorType
>         fields = ('url',
>                   'id',
>                   'customer_part_number',
>                   )
>
> class MotorSerializer(serializers.ModelSerializer):
>     motor_type = SimpleMotorTypeSerializer(source='abc', read_only=True)
>
>     class Meta:
>         model = Motor
>         fields = ('url',
>                   'id',
>                   'motor_type',
>                   ...)
>
>
> The problem is with the source agrument. I just misspelled the source 
> string (inidicated here with "abc", which does not exist).
> My tests didn't throw an error because there is no error thrown at all.
>
> So i am interested how i could avoid this in future (because typing errors 
> are a human thing). Probably testing each single attribute in my JSON 
> response.
>
> But mainly i am asking: 
> Why there is no error raised for a non existing "abc" source?
>
> Greets
> Andi
>
> -- 
> 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 <javascript:>.
> For more options, visit 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