Ticket #5358: 5358_fk_name_fix.diff
File 5358_fk_name_fix.diff, 937 bytes (added by , 17 years ago) |
---|
-
django/newforms/models.py
319 319 fks_to_parent = [f for f in opts.fields if isinstance(f, ForeignKey) and f.rel.to == parent_model] 320 320 if len(fks_to_parent) == 1: 321 321 fk = fks_to_parent[0] 322 fk_name = fk.name 322 323 elif len(fks_to_parent) == 0: 323 324 raise Exception("%s has no ForeignKey to %s" % (model, parent_model)) 324 325 else: 325 326 raise Exception("%s has more than 1 ForeignKey to %s" % (model, parent_model)) 327 else: 328 fk = [f for f in opts.fields if f.name == fk_name][0] 326 329 # let the formset handle object deletion by default 327 330 FormSet = formset_for_model(model, formset=InlineFormset, fields=fields, 328 331 formfield_callback=formfield_callback,