Looks like there is no problem here. Django groups by whatever is in the query, so that this would be done as follows:
On Monday, November 26, 2018 at 12:32:09 PM UTC-5, Dan Davis wrote:
-- Parent.objects.values('id').annotate(child_updated_timestamp=models.Max('child_updated_timestamp'))
On Monday, November 26, 2018 at 12:32:09 PM UTC-5, Dan Davis wrote:
I have a parent model that has a relationship to some data that is changing:class Parent(models.Model):name = models.CharField(...)created_timestamp = models.DateTimeField(auto_now_add=True, null=True) updated_timestamp = models.DateTimeField(auto_now=True, null=True) class Child(models.Model):parent = models.ForeignKey(Parent, on_delete=models.CASCADE)created_timestamp = models.DateTimeField(auto_now_add=True, null=True) updated_timestamp = models.DateTimeField(auto_now=True, null=True) I am trying to annotate a query with a Max updated_timestamp for the children:Parent.objects.annotate(child_updated_timestamp=models.Max(' child__updated_timestamp', output_field=models. DateTimeField())) It seems like Oracle backend is attempting to GROUP BY every field in the child model.Can anyone tell me whether they've seen anything like this and how to constrain the GROUP BY?Thanks,-Dan
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/71f1bd0e-73e9-45ea-8c94-3d83e2015bc9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment