1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

[1.2.X] Fixed #14471 -- Corrected a regression in the use of methods on custom managers on related querysets. Thanks to Lucky for the report.

Backport of r14389 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@14390 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee
2010-10-28 13:00:08 +00:00
parent 3a679cc1c4
commit 29ea1bef21
3 changed files with 40 additions and 5 deletions

View File

@@ -30,7 +30,21 @@ class Person(models.Model):
class Meta:
ordering = ('name',)
# This book manager doesn't do anything interesting; it just
# exists to strip out the 'extra_arg' argument to certain
# calls. This argument is used to establish that the BookManager
# is actually getting used when it should be.
class BookManager(models.Manager):
def create(self, *args, **kwargs):
kwargs.pop('extra_arg', None)
return super(BookManager, self).create(*args, **kwargs)
def get_or_create(self, *args, **kwargs):
kwargs.pop('extra_arg', None)
return super(BookManager, self).get_or_create(*args, **kwargs)
class Book(models.Model):
objects = BookManager()
title = models.CharField(max_length=100)
published = models.DateField()
authors = models.ManyToManyField(Person)
@@ -60,4 +74,3 @@ class UserProfile(models.Model):
class Meta:
ordering = ('flavor',)