mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #13357 -- Minor changes to get Django running under PyPy. Thanks to Alex Gaynor for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12991 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -191,8 +191,8 @@ u'The Definitive Guide to Django: Web Development Done Right'
|
||||
|
||||
# Calling values on a queryset that has annotations returns the output
|
||||
# as a dictionary
|
||||
>>> Book.objects.filter(pk=1).annotate(mean_age=Avg('authors__age')).values()
|
||||
[{'rating': 4.5, 'isbn': u'159059725', 'name': u'The Definitive Guide to Django: Web Development Done Right', 'pubdate': datetime.date(2007, 12, 6), 'price': Decimal("30..."), 'contact_id': 1, 'id': 1, 'publisher_id': 1, 'pages': 447, 'mean_age': 34.5}]
|
||||
>>> [sorted(o.iteritems()) for o in Book.objects.filter(pk=1).annotate(mean_age=Avg('authors__age')).values()]
|
||||
[[('contact_id', 1), ('id', 1), ('isbn', u'159059725'), ('mean_age', 34.5), ('name', u'The Definitive Guide to Django: Web Development Done Right'), ('pages', 447), ('price', Decimal("30...")), ('pubdate', datetime.date(2007, 12, 6)), ('publisher_id', 1), ('rating', 4.5)]]
|
||||
|
||||
>>> Book.objects.filter(pk=1).annotate(mean_age=Avg('authors__age')).values('pk', 'isbn', 'mean_age')
|
||||
[{'pk': 1, 'isbn': u'159059725', 'mean_age': 34.5}]
|
||||
@@ -203,8 +203,8 @@ u'The Definitive Guide to Django: Web Development Done Right'
|
||||
|
||||
# An empty values() call before annotating has the same effect as an
|
||||
# empty values() call after annotating
|
||||
>>> Book.objects.filter(pk=1).values().annotate(mean_age=Avg('authors__age'))
|
||||
[{'rating': 4.5, 'isbn': u'159059725', 'name': u'The Definitive Guide to Django: Web Development Done Right', 'pubdate': datetime.date(2007, 12, 6), 'price': Decimal("30..."), 'contact_id': 1, 'id': 1, 'publisher_id': 1, 'pages': 447, 'mean_age': 34.5}]
|
||||
>>> [sorted(o.iteritems()) for o in Book.objects.filter(pk=1).values().annotate(mean_age=Avg('authors__age'))]
|
||||
[[('contact_id', 1), ('id', 1), ('isbn', u'159059725'), ('mean_age', 34.5), ('name', u'The Definitive Guide to Django: Web Development Done Right'), ('pages', 447), ('price', Decimal("30...")), ('pubdate', datetime.date(2007, 12, 6)), ('publisher_id', 1), ('rating', 4.5)]]
|
||||
|
||||
# Calling annotate() on a ValuesQuerySet annotates over the groups of
|
||||
# fields to be selected by the ValuesQuerySet.
|
||||
|
||||
Reference in New Issue
Block a user