diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-03-12 12:41:58 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-03-12 12:41:58 +0000 |
| commit | 428450b7a90d92239b170160e5926f83085fa476 (patch) | |
| tree | 85f47ae81a123d27c141f0ee4f31409292333793 /docs/db-api.txt | |
| parent | f3ed30f377051c3fef3d184241ed5271fbe61854 (diff) | |
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
Diffstat (limited to 'docs/db-api.txt')
| -rw-r--r-- | docs/db-api.txt | 7 |
1 files changed, 7 insertions, 0 deletions
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`` |
