title: Django return choices with AjaxView
body: <p>I am using two ChoiceFields in my form. The available choices in the second one depend on the one in the first one.<br>
  I created an on change event in my template:</p>
  
  <pre><code>$("#id_department").change(function(){
    console.log($(this).val())
    var department = $(this).val();
    $.ajax({
      type: "POST",
      url : "{% url "load-choices" %}",
      data : {"department" : department},
      success: function(data){
        console.log(data)
        $("#id_usage").append(data);
  
      },
    });
  });
  </code></pre>
  
  <p>which points to my view: </p>
  
  <pre><code>class LoadChoices(View):
      def post(self, request, *args, **kwargs):
          usages = {
              "new": _("New Device is created"),
              "room": _("Room is changed"),
              "owner": _("person currently lending is changed"),
              "reminder": _("Reminder that device is still owned"),
              "overdue": _("Reminder that device is overdue"),
              "trashed": _("Device is trashed")
          }
          department = request.POST["department"]
          used = MailTemplate.objects.values_list('usage', flat=True).filter(department = department)
          valid = [x for x in usages if not any(y in x for y in used)]
          return(HttpResponse(valid))
  </code></pre>
  
  <p><code>usages</code> are the available choices, <code>used</code> are the choices that I do not want to include in the dropdown and <code>valid</code>  are the choices I want to show in the dropdown. Normally, if I was in the edit view, I would just assign <code>valid</code>to the field. 
  But as this is the ajax view, as far as I understand it, I have to return <code>valid</code>.<br>
  But if I try to do that as shown above, the template receives a string like <code>roomownernewremindertrashedoverdue</code> and the dropdown choices do not change, they stay at their initial values that are determined when the form is loaded. (<code>valid</code>, when printed from the ajax view, has this format: <code>[u'room', u'owner', u'new', u'reminder', u'trashed', u'overdue']</code>.)<br>
  Now, for my question: How do I have to format/return these choices and how do I have to pass them to the ChoiceField, if not with <code>append</code>?</p>