title: how to serialize list of form object to JSON in django
body: <p>I'm trying to serialize the form objects and return to the AJAX call so that I can display them in the template, but I'm not able to serialize them unlike serializing the model objects don't we have an option for form objects </p>
  
  <pre><code>if request.method == 'POST':
  
      temp_data_form = TemplateDataForm(request.POST)
  
      if request.POST.get('temp_id'):
          # getting id of the current template 
          existing_template = Template.objects.filter(id=request.POST.get('temp_id'))[0]
          if request.POST.get('item'):
              item_query = existing_template.tempdata_set.filter(item=request.POST.get('item'))
              if item_query:
                  item_query = item_query[0] and True
  
          # we only edit the existing object of the template always as we create the object by default on GET request
          if existing_template and existing_template.title != request.POST.get('title') and request.POST.get('title')!= None:
              existing_template.title = request.POST.get('title')
              existing_template.save()
          if temp_data_form.is_valid() and item_query != True:
  
          # Template items alias data
          td_obj = temp_data_form.save(commit=False)
          td_obj.template = existing_template
          td_obj.save()
  
          values_form = []
  
          for item in existing_template.tempdata_set.all():
              values_form.append(TemplateDataForm(instance=item))
  
          return JsonResponse(values_form, safe=False)
  </code></pre>
  
  <p>I'm getting the below error.</p>
  
  <pre><code>     raise TypeError(f'Object of type {o.__class__.__name__} '
  TypeError: Object of type TemplateDataForm is not JSON serializable
  </code></pre>