Re: How to express `foo = (bar < quox)` as a constraint

2020-01-28 Thread Peter Law
imization ticket > to allow direct usage of Q objects for boolean field lookup right hand sides > > Cheers, > Simon > > https://docs.djangoproject.com/en/3.0/ref/models/expressions/#django.db.models.ExpressionWrapper > > Le lundi 27 janvier 2020 14:32:24 UTC-5, Peter Law a écr

Re: How to express `foo = (bar < quox)` as a constraint

2020-01-27 Thread Peter Law
le = BooleanField() > > class Meta: > constraints = [ > > CheckConstraint(check=Q(is_on_sale=Q(price__lt=F('full_price' > ] > > I haven't tried it myself but I would expect it to work on Django 3.0. > > Cheers, > Simon > > Le lundi 2

Re: How to express `foo = (bar < quox)` as a constraint

2020-01-27 Thread Peter Law
/ref/models/expressions/#using-f-with-annotations > > Item.objects.annotate(is_on_sale=(F('price') < F('full_price'))) > > > > On Mon, Jan 27, 2020 at 11:47 AM Peter Law > > wrote: > >> Hi, >> >> Thanks for adding support for chec

How to express `foo = (bar < quox)` as a constraint

2020-01-27 Thread Peter Law
Hi, Thanks for adding support for check constraints in Django 2.2, it's great to be able to move constraints into the model definitions. I've been trying to work out how to express a constraint which validates that the value of one field expresses a relation between two other fields, but can't fi