#32297: QuerySet.get() method not working as expected with Window functions
-------------------------------------+-------------------------------------
Reporter: Jerin Peter George | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Jerin Peter George):
I am aware that I can do something similar as you suggested for a
''"workaround"'' to get the desired result. But the real question is
whether this is the expected behavior for the Window function?
I am sure that I can do a similar query using the `Count(...)` expression
as
{{{
from django.db import models
class Musician(models.Model):
name = models.CharField(max_length=50)
class Album(models.Model):
artist = models.ForeignKey(Musician, on_delete=models.CASCADE,
related_name="albums")
name = models.CharField(max_length=100)
qs = Musician.objects.annotate(album_count=models.Count("albums"))
print(qs.get(pk=2).album_count)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32297#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/074.ed6d470b5f50b8ce1176116945dacf17%40djangoproject.com.