title: How do I filter ManyToManyField choices in a Django ModelForm?
body: <p>I want to filter ManyToManyField choices in my ModelForm:</p>
  
  <pre><code>class MyForm(forms.ModelForm):
      class Meta:
          model = Entity
          fields = ['parent_entities']
  
      def __init__(self, *args, **kwargs):
          self.root_entity = kwargs.pop('root_entity')
          self.Meta.fields['parent_entities'].queryset = Entity.objects.filter(root_entity=self.root_entity)
          super(MyForm, self).__init__(*args, **kwargs)
  </code></pre>
  
  <p>I tried a lot of different code I've seen but nothing has worked yet.</p>
  
  <p>I guess my problem is that I can't get this 'parent_entities' field.
  With this code, I have the error :</p>
  
  <pre><code>list indices must be integers, not str
  </code></pre>