For what it is worth, it has been confirmed as a bug and fixed: https://code.djangoproject.com/ticket/29142
On Friday, February 9, 2018 at 7:52:50 AM UTC-5, Michael Barr wrote:
-- On Friday, February 9, 2018 at 7:52:50 AM UTC-5, Michael Barr wrote:
According to the documentation on models.OuterRef:It acts like anF
expression except that the check to see if it refers to a valid field isn't made until the outer queryset is resolved.I am experiencing an issue with this using the following example:class ExampleModel(models.Model):
date = models.DateField()
value = models.IntegerField()
subquery = ExampleModel.objects.filter(
date__gte=models.OuterRef('date' ) - timedelta(days=2),
date__lte=models.OuterRef('date' ) + timedelta(days=2),
value__lte=5
)
queryset = ExampleModel.objects.annotate(
value_is_less_than_five=models.Exists(subquery)
)The result that I am getting is:AttributeError: 'ResolvedOuterRef' object has no attribute 'relabeled_clone'From my understanding, if this is similar to an F Expression, you should be able to perform the timedelta on the OuterRef. I also found someone else on StackOverflow with the same issue.What I would like to know is if this is a bug (e.g. should it be supported), or a documentation issue.Thanks in advance for your assistance!
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/4125b377-489a-4875-a233-567137d6ec35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment