From ac67992c7956a663a40516e55dc6f8b7180bd2a0 Mon Sep 17 00:00:00 2001 From: Luke Plant Date: Tue, 31 Jan 2006 23:10:43 +0000 Subject: [PATCH] magic-removal: Fixed (very broken) dynamic creation of method and use of super in last commit, so that RelatedManager works in other contexts now git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2208 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/fields/related.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py index 0e12b1fc29..51f410b8f3 100644 --- a/django/db/models/fields/related.py +++ b/django/db/models/fields/related.py @@ -107,12 +107,13 @@ class ManyRelatedObjectsDescriptor(object): else: # Dynamically create a class that subclasses the related # model's default manager. - manager = types.ClassType('RelatedManager', (self.related.model._default_manager.__class__,), {})() - + superclass = self.related.model._default_manager.__class__ + class_ = types.ClassType('RelatedManager', (superclass,), {}) # Override get_query_set on the RelatedManager def get_query_set(self): - return super(RelatedManager, self).filter(**core_filters) - manager.get_query_set = get_query_set + return superclass.get_query_set(self).filter(**(self.core_filters)) + class_.get_query_set = get_query_set + manager = class_() # Set core_filters on the new manager to limit it to the # foreign-key relationship.