mirror of
https://github.com/django/django.git
synced 2025-07-23 13:15:32 +00:00
Fixed #21846 -- Made NestedObjects handle related_name with %(app_label)s or %(class)s.
This commit is contained in:
parent
a5ec11c4bb
commit
c3fdeb28ff
3 changed files with 32 additions and 3 deletions
|
@ -16,7 +16,7 @@ from django.utils.formats import localize
|
|||
from django.utils.safestring import mark_safe
|
||||
from django.utils import six
|
||||
|
||||
from .models import Article, Count, Event, Location, EventGuide
|
||||
from .models import Article, Count, Event, Location, EventGuide, Vehicle, Car
|
||||
|
||||
|
||||
class NestedObjectsTests(TestCase):
|
||||
|
@ -80,6 +80,16 @@ class NestedObjectsTests(TestCase):
|
|||
# One for Location, one for Guest, and no query for EventGuide
|
||||
n.collect(objs)
|
||||
|
||||
def test_relation_on_abstract(self):
|
||||
"""
|
||||
#21846 -- Check that `NestedObjects.collect()` doesn't trip
|
||||
(AttributeError) on the special notation for relations on abstract
|
||||
models (related_name that contains %(app_label)s and/or %(class)s).
|
||||
"""
|
||||
n = NestedObjects(using=DEFAULT_DB_ALIAS)
|
||||
Car.objects.create()
|
||||
n.collect([Vehicle.objects.first()])
|
||||
|
||||
|
||||
class UtilTests(SimpleTestCase):
|
||||
def test_values_from_lookup_field(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue