title: How to get the list of all attributes of manytomanyfield related model?
body: <p>How to get the list of attributes of a manytomanyfield related model from the other model?</p>
  
  <p>Lets say, we have three models: </p>
  
  <pre><code>class Model1(models.Model):
      name=models.CharField(max_length=255)
  
  class Model2(models.Model):
      name=models.CharField(max_length=255)
  
  class Model3(models.Model):
      name=models.CharField(max_length=255)
      modelone=models.ForeignKey(Model1, on_delete=models.CASCADE)
      modeltwo=models.ManyToManyField(Model2)
  </code></pre>
  
  <p>As you can see that Model3 has foreignkey relation to model1 and ManyTomanyField relation to model2.</p>
  
  <p>Now, to define the serializer:</p>
  
  <pre><code>class Model1Serializer(serializers.ModelSerializer):
      class Meta:
          model=Model1
          fields='__all__'
  
  class Model2Serializer(serializers.ModelSerializer):
      class Meta:
          model=Model2
          fields='__all__'
  
  class Model3Serializer(serializers.ModelSerializer):
      class Meta:
          model=Model3
          fields='__all__'
  </code></pre>
  
  <p>Thus, the current serialized value of model3 is <code>{'id':1,'name':'abc','modelone':2,'modeltwo':[2,3]}</code>
  What I want is:
  <code>{'id':1,'name':'abc','modelone':2,'modeltwo':[2,3],'modeltwo_names':['pqr','xyz'],'modelone_name':'mno'}</code></p>
  
  <p>To have the name of modelone, we can add 
  <code>modelone_name=serializers.CharField(source='modelone.name')</code>
  But, I am not sure how to do it for ManyToManyField?</p>
  
  <p>I tried doing:
  <code>modeltwo_name=serializers.ListField(child=serializers.CharField(source='modeltwo.name'))</code>
  But, doing the above gave me the error:
  <code>AssertionError: The</code>source<code>argument is not meaningful when applied to a</code>child=<code>field. Remove</code>source=<code>from the field declaration.</code></p>