構建 Flask 應用程序,并嘗試按日期/流行度更改條目/卡片的選擇。我被困在這里是因為這個錯誤不是恒定的,它偶爾會觸發。我希望我能讓這個排序功能正常工作,然后看看這個問題,我認為這只是一個小錯誤。但是,現在錯誤更頻繁地觸發,我擔心我只是在這種方法上浪費了我的時間;但我不知道。App.pydef tester(page): limit = 6 offset = (int(page) - 1) * limit requested = request.args.get('fromHTMLchoice') print(requested) requestChoice = requested.split() a = requestChoice[0] b = requestChoice[1] convertChoice = tuple(a[2:-2], int(b[:-1])) sagas_pages = sagas.find().sort( [convertChoice]).skip(offset).limit(limit) return render_template( "tester.html", sagas_pages=sagas_pages, page=page )HTML<form class="form-inline" method="GET" action="{{url_for('tester', page=1)}}"> <div class="form-group"> <div class="input-group"> <span class="input-group-addon">Please select</span> <select name="fromHTMLchoice" class="selectpicker form-control"> <option value= "('totalLikes', -1)">Likes</option> <option value= "('totalLikes', 1)">Dislikes</option> <option value= "('_id', -1)">Most_Recent</option> <option value= "('_id', 1)">Least_Recent</option> </select> </div> <button type="submit" class="btn btn-default">Go</button> </div> </form>
1 回答

繁華開滿天機
TA貢獻1816條經驗 獲得超4個贊
該 AttributeError 是問題的下游。要調試的問題是為什么
requested = request.args.get('fromHTMLchoice') print(requested)
某人打印None
,就像日志頂部一樣。安全的賭注是,不知何故,tester
通過沒有fromHTMLChoice
參數的 URL 被調用。
添加回答
舉報
0/150
提交
取消