mirror of
https://github.com/django/django.git
synced 2025-03-25 16:50:45 +00:00
Refs #20203 -- Added tests to check inherited custom default manager
This commit is contained in:
parent
7866968eb3
commit
c31bf8cb54
@ -194,3 +194,15 @@ class OneToOneRestrictedModel(models.Model):
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
|
class AbstractPerson(models.Model):
|
||||||
|
abstract_persons = models.Manager()
|
||||||
|
objects = models.CharField(max_length=30)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
abstract = True
|
||||||
|
|
||||||
|
|
||||||
|
class PersonFromAbstract(AbstractPerson):
|
||||||
|
pass
|
||||||
|
@ -6,8 +6,8 @@ from django.utils import six
|
|||||||
|
|
||||||
from .models import (
|
from .models import (
|
||||||
Book, Car, CustomManager, CustomQuerySet, DeconstructibleCustomManager,
|
Book, Car, CustomManager, CustomQuerySet, DeconstructibleCustomManager,
|
||||||
FunPerson, OneToOneRestrictedModel, Person, PersonManager,
|
FunPerson, OneToOneRestrictedModel, Person, PersonFromAbstract,
|
||||||
PublishedBookManager, RelatedModel, RestrictedModel,
|
PersonManager, PublishedBookManager, RelatedModel, RestrictedModel,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -512,6 +512,17 @@ class CustomManagerTests(TestCase):
|
|||||||
with self.assertRaisesMessage(ValueError, msg):
|
with self.assertRaisesMessage(ValueError, msg):
|
||||||
mgr.deconstruct()
|
mgr.deconstruct()
|
||||||
|
|
||||||
|
def test_abstract_model_with_custom_manager_name(self):
|
||||||
|
"""
|
||||||
|
A custom manager may be defined on an abstract model.
|
||||||
|
It will be inherited by the abstract model's children.
|
||||||
|
"""
|
||||||
|
PersonFromAbstract.abstract_persons.create(objects='Test')
|
||||||
|
self.assertQuerysetEqual(
|
||||||
|
PersonFromAbstract.abstract_persons.all(), ["Test"],
|
||||||
|
lambda c: c.objects,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestCars(TestCase):
|
class TestCars(TestCase):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user