def _make_model_field(label, initial, choices, multi=True):
 if multi:
  field = forms.models.ModelMultipleChoiceField(choices, required=False)
  field.initial_objs = initial
  field.initial = [obj.pk for obj in initial]
  field.label = label
 else:
  field = forms.models.ModelChoiceField(choices, required=False)
  field.initial_obj = initial
  if initial:
   field.initial = initial.pk
 return field

def _make_model_field ( label , initial , choices , multi = True ) : if multi : field = forms . models . ModelMultipleChoiceField ( choices , required = False ) field . initial_objs = initial field . initial = [ obj . pk for obj in initial ] field . label = label else : field = forms . models . ModelChoiceField ( choices , required = False ) field . initial_obj = initial if initial : field . initial = initial . pk return field
creates multiple choice field with given query object as choices .