title: Django-Nonrel with Mongodb listfield
body: <p>I am trying to implement manytomany field relation in django-nonrel on mongodb. It was suggessted at to:</p>
  
  <p><a href="https://stackoverflow.com/questions/6300218/django-nonrel-form-field-for-listfield">Django-nonrel form field for ListField</a></p>
  
  <p>Following the accepted answer</p>
  
  <p>models.py</p>
  
  <pre><code>class MyClass(models.Model):
      field = ListField(models.ForeignKey(AnotherClass))
  </code></pre>
  
  <p>i am not sure where the following goes, it has been tested in fields.py, widgets,py, models.py</p>
  
  <pre><code>class ModelListField(ListField):
      def formfield(self, **kwargs):
      return FormListField(**kwargs)
  
  class ListFieldWidget(SelectMultiple):
      pass
  
  class FormListField(MultipleChoiceField):
      """
      This is a custom form field that can display a ModelListField as a Multiple Select GUI element.
      """
      widget = ListFieldWidget
  
      def clean(self, value):
      #TODO: clean your data in whatever way is correct in your case and return cleaned data instead of just the value
      return value
  </code></pre>
  
  <p>admin.py</p>
  
  <pre><code>class MyClassAdmin(admin.ModelAdmin):
      form = MyClassForm
  
      def __init__(self, model, admin_site):
      super(MyClassAdmin,self).__init__(model, admin_site)
  
  admin.site.register(MyClass, MyClassAdmin)
  </code></pre>
  
  <p>The following Errors keep popping up:</p>
  
  <p>If the middle custom class code is used in models.py</p>
  
  <pre><code>name 'SelectMultiple' is not defined
  </code></pre>
  
  <p>If custom class code is taken off models.py:</p>
  
  <pre><code>No form field implemented for &lt;class 'djangotoolbox.fields.ListField'&gt;
  </code></pre>