title: Add M2M field using create(): Django
body: <p>I have a lot of doubts about managing the M2m field, I finally got a solution to add that data to a model, but there are still some issues, give me a solution to overcome this,</p>
  <pre><code>class CourseListSerializer(serializers.ModelSerializer):
      instructors = serializers.SerializerMethodField()
      image = FileField()
      keyarea = CourseKeyAreaSerializer
      subject = CourseSubjectsSerializer
      sections = serializers.ListField(write_only=True)
      beneficiaries = serializers.ListField(write_only=True)
      section = CourseSectionSerializers
      beneficiary = CourseBeneficiarySerializer
  
      def create(self, validated_data):
          data = validated_data
          try:
              new = Course.objects.create(image=data['image'], name=data['name'], description=data['description'], is_free=data['is_free'],
                                          keyarea=data['keyarea'], subject=data['subject'])
              new.save()
  
              beneficiary_data = data['beneficiaries']
              new.beneficiary.set(*[beneficiary_data])
              section_data = data['sections']
              new.section.set(*[section_data])
  
              return new
          except Exception as e:
              e = &quot;invalid data&quot;
              return e
  </code></pre>
  <p>here first creating the &quot;new&quot; object after that to set the M2M field like</p>
  <pre><code>&quot;new.beneficiary.set(*[beneficiary_data])&quot;
  </code></pre>
  <p>but is there any way to add beneficiary and section like this</p>
  <pre><code>   &quot;new = Course.objects.create(image=data['image'],name=data['name'], description=data['description'],is_free=data['is_free'],....)&quot;
  </code></pre>