Groups
Groups
Sign in
Groups
Groups
Django users
Conversations
About
Send feedback
Help
Impossible to reproduce example in the documentation of Queryset.values()
16 views
Skip to first unread message
Joseph Lucas
unread,
Jan 17, 2018, 11:37:23 AM
1/17/18
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com, Arnaud Peloquin
Hi,
We were not able to reproduce an example described in Django's documentation, concerning
the value() method of Queryset
.
>>> from django.db.models import Count
>>> Blog.objects.values('author', entries=Count('entry'))
<QuerySet [{'author': 1, 'entries': 20}, {'author': 1, 'entries': 13}]>
When executing above lines with the fixtures described in the docs, we get the following error:
django.core.exceptions.FieldError: Cannot resolve keyword 'author' into field. Choices are: entries, entry, id, name, tagline
This second example from the documentation doesn't seem to work either:
>>> Blog.objects.values('author').annotate(entries=Count('entry'))
<QuerySet [{'author': 1, 'entries': 33}]>
Did we miss something ?
Is the django documentation accurate here ? We wonder how a Blog object could have an 'author' field, given its
model definition
.
Please find attached a minimal project with unittests reproducing these issues.
Sincerely,
Joseph Lucas
Arnaud Peloquin
bug_django_annotate.tar.gz
Tim Graham
unread,
Jan 17, 2018, 1:55:02 PM
1/17/18
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
Confirmed. I opened a bug report:
https://code.djangoproject.com/ticket/29032
.
Reply all
Reply to author
Forward
0 new messages