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
This commit is contained in:
parent
cef5e5421d
commit
ac67992c79
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue