Q: How to update choices for forms.ChoiceField in Django? I have field in forms.py:
main_choices = ((1,'option 1'),(2,'option 2'),(3,'option 3'))
sub_choices = ((1,'PlaceHolder'))
class MainForm(forms.Form):
    type = forms.ChoiceField(choices=main_choices)
    sub_type = forms.ChoiceField(choices=sub_choices)

HTML:
<form action="{% url 'app:get_files' %}" method="POST">
  {% csrf_token %}
  {{ form.type }}
  {{ form.sub_type }}
  <button type="submit" class="app">GET</button>
</form>

view.py
def get_files(request):
    //Some action with complete form
    return FileResponse(zip_file, as_attachment=True)
def get_ajax(request):
    if request.is_ajax():
        data = request.POST.copy()
        if 'type' in data:
            type = int(data['type'])
            if type == 2:
                sub_choices = getChoices(type)
            elif type ==3:
                sub_choices = getChoices(type)
        return HttpResponse()

Currently, server catches ajax post data from the type field.
I don't know how to put sub_choices from get_ajax action to sub_type field in forms.
Can anyone explain how to do that? 
