Du skal bare importere SelectMultiple ved lyden af det. Du kan sætte koden i en af disse tre filer, fields.py ville give mening.
Da det er ret normalt at have:
from django import forms
øverst i din fil allerede, vil du sandsynligvis bare redigere koden nedenfor til:
# you'll have to work out how to import the Mongo ListField for yourself :)
class ModelListField(ListField):
def formfield(self, **kwargs):
return FormListField(**kwargs)
class ListFieldWidget(forms.SelectMultiple):
pass
class FormListField(forms.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
Du vil sikkert også prøve at lære lidt mere om, hvordan python fungerer, hvordan man importerer moduler osv.