Ticket #338: cu.2.diff

File cu.2.diff, 884 bytes (added by mlambert@…, 14 years ago)

Proper Fix for 337 and 338

Line 
1Changes for django/views/generic/create_update.py to fix 337 and 338:
2@@ -119,7 +119,14 @@
3         errors = {}
4         # This makes sure the form acurate represents the fields of the place.
5         new_data = object.__dict__
6-   
7+        #TODO(lambert): merge with latest django code when it comes out
8+        from google3.third_party.python.django.views.admin.main import _get_mod_opts, _get_flattened_data
9+        mod, opts = _get_mod_opts(app_label, module_name)
10+        for f in opts.fields:
11+            new_data.update(_get_flattened_data(f, getattr(object, f.column)))
12+        for f in opts.many_to_many:
13+            new_data[f.name] = [str(i.id) for i in getattr(object, 'get_%s_list' % f.rel.singular)()]
14+
15     form = formfields.FormWrapper(manipulator, new_data, errors)
16     if not template_name:
17         template_name = "%s/%s_form" % (app_label, module_name)
Back to Top