Guest User

Untitled

a guest
Jul 27th, 2013
111
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def make_formset_data(settings, forms):
  2.     data = {}
  3.     for k in settings:
  4.         data['form-'+k.upper()] = settings[k]
  5.     for (n, form) in enumerate(forms):
  6.         for k in form:
  7.             data['form-'+str(n)+'-'+k] = form[k]
  8.     return data
  9.  
  10. data = make_formset_data({
  11.     'total_forms': u'2',
  12.     'initial_forms': u'0',
  13.     'max_num_forms': u''},
  14.     [{ 'title': u'Test', 'pub_date': u'1904-06-16' },
  15.     { 'title': u'Test', 'pub_date': u'1912-06-23' }]
  16. );
  17.  
  18. import pprint
  19. pprint.pprint(data)
RAW Paste Data