title: Django ManytoMany widget to CheckboxSelectMultiple and chained querysets
body: <p>It happened that I needed a ManytoMany field to be displayed as a CheckboxSelectMultiple no problem with that. The trick part is that there are default fields to be displayed and a user should be able to add a new option and this option should be displayed on the form.</p>
  
  <p>Here is what I did:</p>
  
  <p>models.py</p>
  
  <pre><code>class Feature(models.Model):
     name = models.CharField( _("Feature Name"), max_length=40)
     default = models.BooleanField(_("Is Global Feature"), default = False)
  
  class SomeModel(models.Model):
     features = models.ManyToManyField(Feature, related_name='features')
  </code></pre>
  
  <p>forms.py</p>
  
  <pre><code>class FeatureForm(forms.ModelForm):
  def __init__(self, *args, **kwargs):
      somemodel = kwargs['somemodel']
      kwargs.pop('somemodel')
      super(SpaFeatureForm, self).__init__(*args, **kwargs)
      default_features = Feature.objects.filter(default=True)
      custom_features = somemodel.features.filter(default=False)
      q_set = QuerySetChain(default_features, custom_features)
      self.fields['features'].widget = forms.CheckboxSelectMultiple()
      self.fields['features'].queryset = q_set
  
  class Meta:
      model = m.Spa
      fields = ('features',)
  </code></pre>
  
  <p>I'll still implement the second part which will be a feature form and some sort of js to populate the Checkbox Multiselect field choices.</p>
  
  <hr>
  
  <p>I modified @akaihola <a href="https://stackoverflow.com/questions/431628/how-to-combine-2-or-more-querysets-in-a-django-view/432666#432666">answer</a> ow how to chain querysets changing def _all to def all. And it worked fine.</p>
  
  <p>The question now is: Is that the best solution?</p>