私はこのような見解を持っている:ジャンゴ:順序クエリセット
def profile (request):
articles = Post.thing.all()
newSet = set()
def score():
for thing in articles:
Val = some calculation...
....
newSet.update([(thing,Val)])
score()
context = {
'articles': articles.order_by('id'),
'newSet':newSet,
}
return render(request,'my_profile/my_profile.html',context)
と結果は次のようになりますどのクエリセットです。
set([(<thing: sfd>, 1), (<thing: quality>, 0), (<thing: hello>, -1), (<thing: hey>, 4), (<thing: test>, 0)
私は今ではセットを注文しようとしています与えられた値は最高の値から始まるリストですが、私が行うときnewSet.order_by/filter/split/join
'set' object has no attribute join/filter/split
以降は動作しません。
誰でも私にヒントを教えてもらえますか?自分で役立つものは何も見つかりませんでした。
モデルではできない/できないように、ビューで作業するにはこれが必要です。助言をいただきありがとうございます。
セットは発注されていません。なぜあなたは1つを使用していますか?なぜリストではないのですか? –