Kaydet (Commit) e833595b authored tarafından Malcolm Tredinnick's avatar Malcolm Tredinnick

An improved version of the change attempted in [4693]: retain backwards

compatibility with hand-crafted oldforms without breaking edit_inline.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@4698 bcc190cf-cafb-0310-a4f2-bffc1f526a37
üst 90f7616d
...@@ -16,7 +16,7 @@ class RelatedObject(object): ...@@ -16,7 +16,7 @@ class RelatedObject(object):
self.opts = model._meta self.opts = model._meta
self.field = field self.field = field
self.edit_inline = field.rel.edit_inline self.edit_inline = field.rel.edit_inline
self.name = '%s_%s' % (self.opts.app_label, self.opts.module_name) self.name = '%s:%s' % (self.opts.app_label, self.opts.module_name)
self.var_name = self.opts.object_name.lower() self.var_name = self.opts.object_name.lower()
def flatten_data(self, follow, obj=None): def flatten_data(self, follow, obj=None):
......
...@@ -130,7 +130,9 @@ class FormWrapper(object): ...@@ -130,7 +130,9 @@ class FormWrapper(object):
if self.edit_inline: if self.edit_inline:
self.fill_inline_collections() self.fill_inline_collections()
for inline_collection in self._inline_collections: for inline_collection in self._inline_collections:
if inline_collection.name == key: # The 'orig_name' comparison is for backwards compatibility
# with hand-crafted forms.
if inline_collection.name == key or (':' not in key and inline_collection.orig_name == key):
return inline_collection return inline_collection
raise KeyError, "Could not find Formfield or InlineObjectCollection named %r" % key raise KeyError, "Could not find Formfield or InlineObjectCollection named %r" % key
...@@ -226,6 +228,9 @@ class InlineObjectCollection(object): ...@@ -226,6 +228,9 @@ class InlineObjectCollection(object):
self.errors = errors self.errors = errors
self._collections = None self._collections = None
self.name = rel_obj.name self.name = rel_obj.name
# This is the name used prior to fixing #1839. Needs for backwards
# compatibility.
self.orig_name = rel_obj.opts.module_name
def __len__(self): def __len__(self):
self.fill() self.fill()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment