title: Django extract string from [ErrorDetail(string='Test Message', code='invalid')]
body: <p>I would like to show in my template only message that is in string variable, but I don't know how. I am using Django Rest Framework. My code:</p>
  
  <p>form.html</p>
  
  <pre><code>&lt;p&gt;{{ serializer.amount.errors }}&lt;/p&gt;
  </code></pre>
  
  <p>serializers.py</p>
  
  <pre><code>from rest_framework import serializers
  from .models import Data, Material
  
  
  class DataSerializer(serializers.ModelSerializer):
  
  class Meta:
      model = Data
      fields = ('order_date', 'material', 'amount', 'delivery_number', 'employee')
      read_only_fields = ('id', 'insert_time')
      extra_kwargs = {"amount": {"error_messages": {"invalid": "Test Message"}}}
  </code></pre>
  
  <p>views.py</p>
  
  <pre><code>class Form(APIView):
  
  renderer_classes = [TemplateHTMLRenderer]
  template_name = 'zulieferung/form.html'
  
  def get(self, request):
      materials = Material.objects.distinct('material_unit_id')
      return Response({'all_materials': materials})
  
  def post(self, request):
      materials = Material.objects.all()
      serializer = DataSerializer(data=request.data)
      if serializer.is_valid():
          serializer.save()
          return Response({'all_materials': materials}, status=status.HTTP_201_CREATED)
      return Response({'serializer': serializer}, status=status.HTTP_400_BAD_REQUEST)
  </code></pre>
  
  <p>And instead of <strong><em>Test Message</em></strong> in my template I have <strong><em>[ErrorDetail(string='Test Message', code='invalid')]</em></strong></p>
  
  <p><a href="https://i.stack.imgur.com/3xBvz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3xBvz.png" alt="enter image description here"></a></p>