def construct_instance(form, instance, fields=None, exclude=None):
 from django.db import models
 opts = instance._meta
 cleaned_data = form.cleaned_data
 file_field_list = []
 for f in opts.fields:
  if ((not f.editable) or isinstance(f, models.AutoField) or (not (f.name in cleaned_data))):
   continue
  if ((fields is not None) and (f.name not in fields)):
   continue
  if (exclude and (f.name in exclude)):
   continue
  if isinstance(f, models.FileField):
   file_field_list.append(f)
  else:
   f.save_form_data(instance, cleaned_data[f.name])
 for f in file_field_list:
  f.save_form_data(instance, cleaned_data[f.name])
 return instance

def construct_instance ( form , instance , fields = None , exclude = None ) : from django . db import models opts = instance . _meta cleaned_data = form . cleaned_data file_field_list = [ ] for f in opts . fields : if ( ( not f . editable ) or isinstance ( f , models . AutoField ) or ( not ( f . name in cleaned_data ) ) ) : continue if ( ( fields is not None ) and ( f . name not in fields ) ) : continue if ( exclude and ( f . name in exclude ) ) : continue if isinstance ( f , models . FileField ) : file_field_list . append ( f ) else : f . save_form_data ( instance , cleaned_data [ f . name ] ) for f in file_field_list : f . save_form_data ( instance , cleaned_data [ f . name ] ) return instance
constructs and returns a model instance from the bound forms cleaned_data .