From 428450b7a90d92239b170160e5926f83085fa476 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Wed, 12 Mar 2008 12:41:58 +0000 Subject: queryset-refactor: Refactored the way values() works so that it works properly across inherited models. Completely by accident, this also allows values() queries to include fields from related models, providing it is crossing a single-valued relation (one-to-one, many-to-one). Many-to-many values() fields still aren't supported, since that requires actual thinking. So this refs #5768. git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7230 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/db-api.txt | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'docs') diff --git a/docs/db-api.txt b/docs/db-api.txt index e626d1da86..af5ba8ce49 100644 --- a/docs/db-api.txt +++ b/docs/db-api.txt @@ -596,6 +596,13 @@ Example:: >>> Blog.objects.values('id', 'name') [{'id': 1, 'name': 'Beatles Blog'}] +You can also retrieve values from across ``ForeignKey`` relations by using +double underscores to separate the field names, just as when calling the +``filter()`` command. For example:: + + >>> Entry.objects.values('blog__name').distinct() + [{'name': 'Beatles Blog'}] + A couple of subtleties that are worth mentioning: * The ``values()`` method does not return anything for ``ManyToManyField`` -- cgit v1.3