title: How to write a Serializer for array data in REST API in Django Rest Framework?
body: <p>I have written basic model serializers in Django where the api mimics the data model. I now have a requirement to store User Preference in database. The api contains an array.</p>
  
  <p>My User Models :</p>
  
  <pre><code>class User(models.Model):
      email_id = models.EmailField(max_length=80, blank=True, primary_key=True)
  
  class UserPreference(models.Model)
      email_id = models.ForeignKey('User')
      preference = models.CharField(maxlength=20)
  </code></pre>
  
  <p>An ideal json post request would look something like this</p>
  
  <pre><code>{
      email:"abhishek@gmail.com"
      preference : [ 'books', 'food', 'lifestyle', 'travel']
  }
  </code></pre>
  
  <p>I wish to save this json schema to the <code>UserPreference</code> model. This requires multiple inserts for preference.  What will be a good serializer design for it ?</p>
  
  <p>I tried    </p>
  
  <pre><code>class UserPreferenceSerializer(serializers.ModelSerializer):
      class Meta:
          model = UserPreference
          fields = ('email_id', 'preference')
  </code></pre>