From 43809de79db2dfd3f967f4c95bca98f8f6c75fb5 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Thu, 8 Mar 2007 03:21:35 +0000 Subject: Fixed #1839, #2415, #2536 -- Fixed a generated name clash that was common in self-referential and circular relations. A lot of community debugging went into this fix, so thanks to bmurdock@gmail.com, Marek Kubica, ramiro, Michael Radziej (the last two giving test cases showing the problem) and James Bennett (who did the hard work to actually diagnose the true problem and fix it). git-svn-id: http://code.djangoproject.com/svn/django/trunk@4676 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/related.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'django') diff --git a/django/db/models/related.py b/django/db/models/related.py index a63f09b745..8c64b464ec 100644 --- a/django/db/models/related.py +++ b/django/db/models/related.py @@ -1,7 +1,7 @@ class BoundRelatedObject(object): def __init__(self, related_object, field_mapping, original): self.relation = related_object - self.field_mappings = field_mapping[related_object.opts.module_name] + self.field_mappings = field_mapping[related_object.name] def template_name(self): raise NotImplementedError @@ -16,7 +16,7 @@ class RelatedObject(object): self.opts = model._meta self.field = field self.edit_inline = field.rel.edit_inline - self.name = 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): -- cgit v1.3