-
- 个人中心—视图函数带标签页面参数tag@app.route('/usercenter/<user_id>/<tag>')def usercenter(user_id, tag): if tag == ‘1': return render_template('usercenter1.html', **context)
- 个人中心—导航标签链接增加tag参数<li role=“presentation”><a href=“{ { url_for(‘usercenter’,user_id = user.id,tag = ‘1’) }}">全部问答</a></li>
- 个人中心—有链接到个人中心页面的url增加tag参数u <a href="{ { url_for('usercenter',user_id = session.get('userid'), tag=1) }}">{ { session.get('user') }}</a>
-
@app.route('/usercenter/
/ ')def usercenter(user_id,tag): user = User.query.filter(User.id == user_id).first() context = { 'usern': user.id, 'username': user.username, 'fankui':user.fankui, 'comment':user.comment } if tag =='1': return render_template('usercenter1.html',**context) elif tag == '2': return render_template('usercenter2.html', **context) else: return render_template('usercenter3.html', **context) -
{% extends'danghangye.html' %}{% block title %}个人中心{% endblock %}{% block head %}{% endblock %}{% block main %}
{% block usercenter %}{% endblock %}{% endblock %}{% block head %}{% endblock %}
{% block title %}{% endblock %}首页 {% block main %}{
{username}}请登录{% for foo in fankui %} {% endblock %}- { {foo.author.username}}评论({ {foo.comment|length}}) { {foo.biaoti}} { {foo.creat_time}}
{% endfor %}{
{foo.questionDetail}} - { {foo.author.username}}评论({ {foo.comment|length}}) { {foo.biaoti}} { {foo.creat_time}}