0

我正在尝试使用 peewee 模型在我的 Flask 应用程序中对结果进行分页,但出现此错误:

... File "/home/pi/ehome/main/app.py", line 148, in financeAll return object_list('/financeAllTrans.html', trans_list) NameError: name 'object_list' is not defined

如果我使用 render_template 而不是 object_list 它可以工作(显然没有分页)。我在谷歌上找不到任何线索:/

模型.py

class Finance(object):
    def __init__(self):
            finDB.get_conn()

    def get_all_transactions(self):
            return transactions.select().order_by(transactions.trans_date.desc()).limit(30)

应用程序.py

app = Flask(__name__)
app.config['MODEL'] = model.DHTData()
app.config['MODEL2'] = model.Finance()

@app.route("/financeAll")
def financeAll():
    trans_list = model.Finance().get_all_transactions()
    return object_list('/financeAllTrans.html', trans_list)

.html

{% for transaction in trans_list %}
...
<input type="text" class="form-control" name="{{ transaction.id }}" id="{{ transaction.id }}" value="{{ transaction.id }}">
<div class="col-sm-2"><input type="text" class="form-control" name="trans_date" value="{{ transaction.trans_date }}"></div>

...                     

{% endfor %}
     </div>
{% if page > 1 %}
    <a class="previous" href="./?page={{ page - 1 }}">Previous</a>
{% endif %}
{% if pagination.get_page() > page %}                                          
    <a class="next" href="./?page={{ page + 1 }}">Next</a>
{% endif %}

谢谢

4

0 回答 0