GameSession.objects.filter(GreaterThan('user__profile__last_login_date', yesterday))
# or, if last_login was a datetime, and we wanted to compare the date part only
GameSession.objects.filter(Equal(Date('user__profile__last_login'), datetime.now().date))
# or if we wanted to implement __gt__ and __eq__ etc:
GameSession.objects.filter(Date('user__profile__last_login') == datetime.now().date))
GameSession.objects.filter(E('user__profile__last_login').date() == datetime.now().date)
Article.objects.filter(E('headline').collate('fi') == 'Article1')
GameSession.objects.filter(Equal(Date(Q.user.profile.last_login), datetime.now().date))
GameSession.objects.filter(E(Q.user.profile.last_login).date() == datetime.now().date)
GameSession.objects.filter(Equal(Date(F.user.profile.last_login), datetime.now().date))
GameSession.objects.filter(E(F.user.profile.last_login).date() == datetime.now().date)
+-------------------+---------------------------+----------------------+
| Class/Function | Allowed Param Types | Comparison Operators |
+-------------------+---------------------------+----------------------+
| Transform | str, P, Transform, Lookup | Return lookup |
| Lookup | str, P, Transform | Raise exception |
| P | | Return lookup |
| .order_by | str, P | |
| .select_related | str, P | |
| .prefetch_related | str, P, Prefetch | |
+-------------------+---------------------------+----------------------+
I strongly agree with the third party approach.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CALMtK1EgXq3CRW8oseE8Uug7ZH%3DEQpFUEVKbMS-4Z%2B%2BwJXbEAA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CALMtK1EgXq3CRW8oseE8Uug7ZH%3DEQpFUEVKbMS-4Z%2B%2BwJXbEAA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
...
...
Model.objects.order_by(P.related.date_field().desc())
Model.objects.order_by(Model.related.date_field.desc())
...
...
...
GameSession.objects.filter(GreaterThan('user__profile__last_login_date', yesterday))
...
I don't think complex cases need to have __ equivalents, but I also dispute that long chains like that are necessarily a bad API, I don't find your option 1 particularly neat compared to option 2. Worth noting though that you've used a 2-valued function there which is not a lookup in the same sense.
I think data__owner__other_pets__0__name is as nice to read as JSONExtract('data', path=['owner', 'other_pets', 0, 'name']) personally.
Marc
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/4cf190c2-ceb9-40c5-a5c4-f2df266d0888%40googlegroups.com.
Several comments:
...
>>> Q.data.owner.other_pets[0].name='Fishy' Q(data__owner__other_pets__0__name='Fishy') >>> Q.tags[0] == 'thoughts' Q(tags__0='thoughts') >>> Q.tags[0:2].contains(['thoughts']) Q(tags__0_2__contains=['thoughts'])
>>> Q.user.username.contains('Rodriguez') Q(user__username__contains='Rodriguez')
>>> Q.user.create_datetime.range(d1, d2) Q(user__create_datetime__range=(d1, d2))
# interface
>>> class ExpressionBuilder:... def get_expression(self):
... pass
# calling get_expression function of the instance below
# should raise error as right hand expression is not created yet
>>> Builder.user.first_name.lower()<ExpressionBuilder object at 0x7f3605145080>
# calling get_esxpression method of the instance below
# will return a full expression tree
>>> Builder.user.first_name.lower().collate('fi') == 'anssi'
<ExpressionBuilder object at 0x7f3604f96400>
# query itself
qs = MyModel.objects.filter(ThirdParty.user.first_name.collate('fi').lower() == 'anssi')
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/b0e30b7f-524e-4cbf-9bba-37cbb8425edc%40googlegroups.com.--
You received this message because you are subscribed to a topic in the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-developers/W0OYXhavY68/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-developers+unsubscribe@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
In []: from model_values import F
In []: F.user.created
Out[]: FExpr(user__created)
In []: F.user.created >= 0
Out[]: <Q: (AND: ('user__created__gte', 0))>
In []: F.user.created.min()
Out[]: Min(FExpr(user__created))
In []: -F.user.created
Out[]: OrderBy(FExpr(user__created), descending=True)
In []: F.text.iexact('...')
Out[]: <Q: (AND: ('text__iexact', '...'))>
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/cb6fe10a-5db9-4199-acc1-d3b8c00fdfcfn%40googlegroups.com.