From 324f717c5e7e2e62963e6a3e4f57d3099bfdeaef Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Fri, 2 Sep 2005 16:34:14 +0000 Subject: [PATCH] Fixed bug in has_related_links=True, which is legacy and shouldn't be used by anybody git-svn-id: http://code.djangoproject.com/svn/django/trunk@601 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/meta/__init__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/django/core/meta/__init__.py b/django/core/meta/__init__.py index cd0f306320..7a372f5065 100644 --- a/django/core/meta/__init__.py +++ b/django/core/meta/__init__.py @@ -299,18 +299,19 @@ class Options: rel_objs.append((klass._meta, f)) if self.has_related_links: # Manually add RelatedLink objects, which are a special case. - core = get_module('relatedlinks', 'relatedlinks') + relatedlinks = get_module('relatedlinks', 'relatedlinks') # Note that the copy() is very important -- otherwise any # subsequently loaded object with related links will override this # relationship we're adding. - link_field = copy.copy(core.RelatedLink._meta.get_field('object_id')) + link_field = copy.copy(relatedlinks.RelatedLink._meta.get_field('object_id')) link_field.rel = ManyToOne(self.get_model_module().Klass, 'id', num_in_admin=3, min_num_in_admin=3, edit_inline=TABULAR, lookup_overrides={ 'content_type__package__label__exact': self.app_label, - 'content_type__python_module_name__exact': self.module_name + 'content_type__python_module_name__exact': self.module_name, + 'object_id__id__exact': None, }) - rel_objs.append((core.RelatedLink._meta, link_field)) + rel_objs.append((relatedlinks.RelatedLink._meta, link_field)) self._all_related_objects = rel_objs return rel_objs @@ -1532,7 +1533,7 @@ def manipulator_save(opts, klass, add, change, self, new_data): else: params[f.column] = f.get_manipulator_new_data(rel_new_data, rel=True) # Related links are a special case, because we have to - # manually set the "content_type_id" field. + # manually set the "content_type_id" and "object_id" fields. if opts.has_related_links and rel_opts.module_name == 'relatedlinks': contenttypes_mod = get_module('core', 'contenttypes') params['content_type_id'] = contenttypes_mod.get_object(package__label__exact=opts.app_label, python_module_name__exact=opts.module_name).id