@app.route('/user_detail<user_id>')
@login_first
def user_detail(user_id):
user=User.query.filter(User.id == user_id).first()
context={
"user":user
}
return render_template("user.html",**context)
{% extends "base.html" %}
{% block title%}用户详情{% endblock %}
{% block head %}
<style>
.u_ul li{
float: left;
margin: 20px;
list-style: none;
}
</style>
{% endblock %}
{% block main %}
<ul class="u_ul">
<li role="presentation"><a href="{{ url_for("user_detail",user_id = user.id)}}">全部问答</a></li>
<li role="presentation"><a href="{{ url_for("user_detail",user_id = user.id)}}">全部评论</a></li>
<li role="presentation"><a href="{{ url_for("user_detail",user_id = user.id)}}">个人信息</a></li>
</ul>
{% block user %}{% endblock %}
{% endblock %}
{% extends "user.html" %}
{% block user %}
<form class="basic">
{% for foo in user.question %}
<h2>{{ foo.username }}<span>全部问答</span></h2>
<fieldset>
<span >{{ foo.create_time }}</span>
<h3>{{ foo.title }}</h3>
<h3>{{ foo.detail}}</h3>
</fieldset>
{% endfor %}
</form>
{% endblock %}
{% extends "user.html" %}
{% block user %}
<form class="basic">
{% for foo in user.comment %}
<h2>{{ foo.username }}<span>全部评论</span></h2>
<fieldset>
<span>{{ foo.create_time }}</span>
<h3>{{ foo.detail}}</h3>
</fieldset>
{% endfor %}
</form>
{% endblock %}
{% extends "user.html" %}
{% block user %}
<form class="basic">
<fieldset>
<span>个人信息</span>
<ul>
<li>用户:{{ user.username }}</li>
<li>编号:{{ user.id }}</li>
<li>文章篇数:{{ user.question|length }}</li>
</ul>
</fieldset>
</form>
{% endblock %}