title: Django serializers: What does is_valid actually do?
body: <p><a href="https://github.com/ajmaln/DRF-Chat" rel="noreferrer">git repo</a>:
  <a href="https://utopian.io/utopian-io/@ajmaln/part-1-creating-a-simple-chat-app-with-djangorestframework" rel="noreferrer">django tutorial</a></p>
  
  <p>I've been following the above django project that looks at creating at person to person chat. I've come across this part:</p>
  
  <pre><code>def message_list(request, sender=None, receiver=None):
      ...
  
      elif request.method == 'POST':
          print('posting')
          data = JSONParser().parse(request)
          print(data)
          serializer = MessageSerializer(data=data)
          print(serializer)
          if serializer.is_valid():
              serializer.save()
              return JsonResponse(serializer.data, status=201)
  
  class MessageSerializer(serializers.ModelSerializer):
      sender = serializers.SlugRelatedField(many=False, slug_field='email', queryset=User.objects.all())
      receiver = serializers.SlugRelatedField(many=False, slug_field='email', queryset=User.objects.all())
  
      class Meta:
          model = Message
          fields = ['sender', 'receiver', 'message', 'timestamp']
  </code></pre>
  
  <p>What does <code>"if serializer.is_valid():"</code> actually do? Is it checking that the data in the message matches the data in the user profile? I've never used serializers before and could use an explanation of it.</p>
  
  <p>Thanks</p>