1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

[4.2.x] Fixed #34458 -- Fixed QuerySet.defer() crash on attribute names.

Thanks Andrew Cordery for the report.

Regression in b3db6c8dcb.

Backport of 87c63bd8df from main
This commit is contained in:
Simon Charette
2023-04-04 16:58:15 -04:00
committed by Mariusz Felisiak
parent 272dc386c2
commit 647920b766
3 changed files with 9 additions and 2 deletions

View File

@@ -178,6 +178,11 @@ class DeferTests(AssertionMixin, TestCase):
obj = ShadowChild.objects.defer("name").get()
self.assertEqual(obj.name, "adonis")
def test_defer_fk_attname(self):
primary = Primary.objects.defer("related_id").get()
with self.assertNumQueries(1):
self.assertEqual(primary.related_id, self.p1.related_id)
class BigChildDeferTests(AssertionMixin, TestCase):
@classmethod