def initial(form):
 data = {}
 for (name, field) in form.fields.items():
  if form.is_bound:
   data[name] = form[name].data
  else:
   data[name] = form.initial.get(name, field.initial)
  if isinstance(field, forms.BooleanField):
   val = field.to_python(data[name])
   if (not val):
    del data[name]
 return data

def initial ( form ) : data = { } for ( name , field ) in form . fields . items ( ) : if form . is_bound : data [ name ] = form [ name ] . data else : data [ name ] = form . initial . get ( name , field . initial ) if isinstance ( field , forms . BooleanField ) : val = field . to_python ( data [ name ] ) if ( not val ) : del data [ name ] return data
gather initial data from the form into a dict .