title: How to insert character varying array into postgresql
body: <p>I want to insert a json array into postgresql?This is my code:</p>
  
  <pre><code>def post(self,request):
      request_data = '''
        {
          "name":"a",
          "isbn":"dd",
          "author":["a","b"],
          "publisher":["a","b"],
          "price":"ddd"}
      '''
      data = json.loads(request_data)
      serializer = BookSerializer(data=data)
      if serializer.is_valid():
          serializer.save()
          return JsonResponse(serializer.data, status=201)
      return JsonResponse(serializer.errors, status=400)
  </code></pre>
  
  <p>And this is my field define:</p>
  
  <pre><code>class BookSerializer(serializers.Serializer):                
      name = serializers.CharField(required=False, allow_blank=True, max_length=100)
      isbn = serializers.CharField(required=False, allow_blank=True, max_length=100)
      author = serializers.ListField(required=False)
      publisher = serializers.ListField(required=False, max_length=100)
      price = serializers.CharField(required=False, allow_blank=True, max_length=100)
  </code></pre>
  
  <p>And the book define in the model is:</p>
  
  <pre><code>class Book(models.Model):
      name = models.CharField(max_length=256, blank=True, default='')
      isbn = models.CharField(max_length=16,blank=False)
      author = models.CharField(max_length=16,blank=False)
      publisher = models.CharField(max_length=16,blank=False)
      price = models.CharField(max_length=16,blank=False)
  
      class Meta:
          db_table = 'book'
  </code></pre>
  
  <p>When I am request the function,the error stack output like this:</p>
  
  <pre><code> malformed array literal: "['a', 'b']"
  LINE 1: ...author", "publisher", "price") VALUES ('a', 'dd', '[''a'', '...
                                                               ^
  DETAIL:  "[" must introduce explicitly-specified array dimensions.
  Request Method: GET
  Request URL:    http://localhost:8000/spider/api/book
  Django Version: 2.1.3
  Exception Type: DataError
  Exception Value:    
  malformed array literal: "['a', 'b']"
  LINE 1: ...author", "publisher", "price") VALUES ('a', 'dd', '[''a'', '...
                                                               ^
  DETAIL:  "[" must introduce explicitly-specified array dimensions.
  Exception Location: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/utils.py in _execute, line 85
  Python Executable:  /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
  Python Version: 3.7.1
  Python Path:    
  ['/Users/dolphin/source/pydolphin',
   '/Library/Frameworks/Python.framework/Versions/3.7/lib/python37.zip',
   '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7',
   '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload',
   '/Users/dolphin/Library/Python/3.7/lib/python/site-packages',
   '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages']
  Server time:    Sun, 25 Nov 2018 15:42:19 +0000
  </code></pre>
  
  <p>How to avoid this problem?</p>