我正在尝试在 Django 中编写一个过滤器,我首先过滤查询集,然后我想再次使用以下 SQL-statemnet 过滤它:
SELECT * FROM user,
(select EXTRACT(year FROM age(birthday)) as age FROM user) as age
WHERE age.age between 20 AND 40;
我怎样才能做到这一点?
编辑:模型如下
class User(models.Model):
first_name = models.CharField(max_length=50)
birthday = models.DateField()