Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
検索条件によって異なるフィルター クエリがあります。
時々それは:
Thing.object.filter(name__startswith=word).distinct('id')
そして時折:
Thing.object.filter(city__startswith=word)
したがって、その後のすべて.filter(が変更される可能性があります。これを動的に設定する方法はありますか?
.filter(
への引数.filter()、はい。辞書を作成するだけです。
.filter()
D = {'city__startswith': word} things = Thing.object.filter(**D)
への電話.distinct()、いいえ。特殊なケースが必要になります。
.distinct()