Hi,

serializer.data should only be used for serialization.
If you try to access it during deserialization, you’ll get a warning from the 
framework:

serializer = SnippetSerializer(snippet)
serializer.data
or

serializer = SnippetSerializer(data=data)
serializer.is_valid()
serializer.validated_data
serializer.save()
But in the latter case, you can’t call serializer.data (doesn’t make sense 
either as you provided the data in the first place).

Hopes this helps,
Xavier Ordoquy,
Linovia.


> Le 19 juin 2017 à 16:05, mrlemon <matthew.le...@gmail.com> a écrit :
> 
> Hi - just come to DRF; exploring for an upcoming project.
> 
> Is there an oversight in the tutorial 
> (http://www.django-rest-framework.org/tutorial/1-serialization/) or am I 
> doing something wrong?
> 
> The framework guards against calling serializer.data,but states that you do 
> so in the tutorial.
> 
> I see the issue <https://github.com/encode/django-rest-framework/issues/2490> 
> on this, but it's I'm still getting the error when restarting the shell and 
> following the tutorial without calling serializer.data.
> 
> Any advice welcome.
> 
> 
> 
> 
> 
> 
> -- 
> 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