0
我正在嘗試爲我的ORM queryset設置過濾器的字典。 這是我的字典:Django orm過濾器是字典的元素
section = self.kwargs['section'] # hot or new or trending
threshold = {'hot': 'post_upvotes > 50', 'trending': 'post_upvotes__range=(20,50)', 'new': 'post_upvotes < 20'}
return Post.objects.filter(threshold[section])
但它不起作用。
我該如何做到這一點?
感謝的人。就是這樣。 – Sekai