django F-expressions and Q-expressions

1.from django.db.models import F (forgot to search in existing projects)
For example, if we want to check the data of field1<filed2 in the database, we need to use querySet.filter(**{'field1__lt':F('field2')}) or simply querySet.filter(field1__lt=F('field2')) 
The way of writing F is exactly the same as passing specific parameters as SQL conditions, but it directly uses the fields in the database.
See https://cn.aliyun.com/jiaocheng/451495.html


2.from django.db.models import Q ( Forgot to search in existing projects)

See: https://www.colabug.com/2309808.html (this link also has time span query Entry . objects . filter ( mod_date__gt = F ( 'pub_date' ) + timedelta ( days = 3 )) ) 
 


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325217100&siteId=291194637