From 8b1aebbf352cd2c7e0c3bd81b83553fe293ad56a Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Fri, 30 Apr 2010 16:32:48 +0000 Subject: Fixed #12851 -- Another attempt at fixing select_related() with inherited models, this time with only(). Thanks to phxx for the test case. git-svn-id: http://code.djangoproject.com/svn/django/trunk@13059 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/select_related_regress/models.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests') diff --git a/tests/regressiontests/select_related_regress/models.py b/tests/regressiontests/select_related_regress/models.py index c99bee0f7e..a673809369 100644 --- a/tests/regressiontests/select_related_regress/models.py +++ b/tests/regressiontests/select_related_regress/models.py @@ -197,4 +197,13 @@ u'Troy Buswell' >>> troy.state.name u'Western Australia' +# Also works if you use only, rather than defer +>>> troy = SpecialClient.objects.select_related('state').only('name').get(name='Troy Buswell') +>>> troy.name +u'Troy Buswell' +>>> troy.value +42 +>>> troy.state.name +u'Western Australia' + """} -- cgit v1.3