Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit e833595bc836f2c26c5acee54b8d083be07c6858 1 parent 90f7616
@malcolmt malcolmt authored
Showing with 7 additions and 2 deletions.
  1. +1 −1  django/db/models/related.py
  2. +6 −1 django/oldforms/__init__.py
View
2  django/db/models/related.py
@@ -16,7 +16,7 @@ def __init__(self, parent_model, model, field):
self.opts = model._meta
self.field = field
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()
def flatten_data(self, follow, obj=None):
View
7 django/oldforms/__init__.py
@@ -130,7 +130,9 @@ def __getitem__(self, key):
if self.edit_inline:
self.fill_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
raise KeyError, "Could not find Formfield or InlineObjectCollection named %r" % key
@@ -226,6 +228,9 @@ def __init__(self, parent_manipulator, rel_obj, data, errors):
self.errors = errors
self._collections = None
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):
self.fill()
Please sign in to comment.
Something went wrong with that request. Please try again.