-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Open
Labels
Description
I have this situation:
class LocationSerializer(serializers.Serializer):
country = serializers.CharField(min_length=2, max_length=2)
city = serializers.CharField(max_length=200)
latitude = serializers.FloatField()
longitude = serializers.FloatField()
class UserDetailSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields = ('location', )
location = LocationSerializer(partial=False)
if I use UserDetailSerializer(partial=true)
in a view and pass this in json:
{
"location": {}
}
it will be validated because of this code part in fields.py:340
if data is empty:
if getattr(self.root, 'partial', False):
raise SkipField()
if self.required:
self.fail('required')
return (True, self.get_default())
I think it should be self.parent
instead of self.root
mpranjic