当我请求tag_list视图时,posts变量未列出数据。 更改其在self_entries视图上方的位置后,一切正常。 但是现在我无法获取self_entries查看数据。 我在这里想念的是什么? 更改位置后,所有内容均按预期下降,但位于底部的视图完全不显示数据。
@app.route('/entries')
@login_required
def list():
posts = models.Journal.select().order_by(models.Journal.created_at.desc())
return render_template("entries.html", posts=posts)
# This View Works as expected
@app.route('/entries/<username>')
@login_required
def self_entries(username):
posts = (models.Journal
.select(models.User, models.Journal)
.join(models.User)
.where(models.User.username**username)
.order_by(models.Journal.created_at.desc())
)
# for post in posts:
# print(post.title + str(post.created_at.date()) + post.tag)
return render_template("entries.html", posts=posts)
# This view doesn't... the page displays as empty
@app.route('/entries/<tag>')
@login_required
def tag_list(tag):
posts = (models.Journal
.select()
.where(models.Journal.tag == tag)
.order_by(models.Journal.created_at.desc())
)
return render_template("entries.html", posts=posts)
entries.html
{% extends "layout.html" %}
{% block content %}
<div>
<div>
<h1>{{ hi }}</h1>
{% for post in posts %}
<article>
<h2><a href="{{ url_for('detail', slug=post.slug ) }}">{{ post.title }}</a></h2>
<time datetime="{{ post.created_at }}">{{ post.created_at.date() }}</time>
<h3><a href="{{ url_for('tag_list', tag=post.tag) }}" >{{ post.tag }}</a><h3>
</article>
{% endfor %}
</div>
</div>
{% endblock %}
答案 0 :(得分:0)
确定。以下两种路线都使用类似的API,即。 '/ entries /',因此存在冲突。所以换一个。
val intent : Intent = this.intent
intent.getStringExtra("articleImg")?.let { mArticleImg = it }
intent.getParcelableExtra("data")?.let { mArticle = it }
将@app.route('/entries/<username>')
@app.route('/entries/<tag>')
更改为@app.route('/entries/<tag>')
。