Hi, We were not able to reproduce an example described in Django's documentation, concerning the value() method of Queryset <https://docs.djangoproject.com/en/1.11/ref/models/querysets/#values>.
>>> 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
<https://docs.djangoproject.com/en/1.11/topics/db/queries/#>.
Please find attached a minimal project with unittests reproducing these
issues.
Sincerely,
Joseph Lucas
Arnaud Peloquin
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/57c7cd56-2ae8-8d9e-f5b3-86314ac4665a%40abolis.fr.
For more options, visit https://groups.google.com/d/optout.
bug_django_annotate.tar.gz
Description: application/gzip

