form app.models import XXX
query = XXX.objects.all()
query = query.filter(name=123, age=456).filter(salary=999)
class Query:
def filter(self):
pass
query = Query()
query.filter().filter()
[attach]430[/attach]
class Query:
def filter(self):
return self
query = Query()
query.filter().filter()
class Query():
def __init__(self):
self.query_condition = {}
def filter(self, **kwargs):
self.query_condition.update(kwargs)
return self
query = Query()
a = query.filter(name='kingname').filter(age__gt=15, address='yyyyyy').filter(salary=99999)
print(query.query_condition)
欢迎光临 大内高手社区 (https://bbs.tedu.cn/) | Powered by Discuz! X3.4 |