实现逻辑: {% if request.user.is_authenticated %} 个人信息{% else %}登录{% endif %}
直接上代码
{% if request.user.is_authenticated %} <div class=http://www.likecs.com/"personal"> <dl class=http://www.likecs.com/"user fr"> <dd>{{ request.user.username }}<img class=http://www.likecs.com/"down fr" src=http://www.likecs.com/"/static/images/top_down.png"/></dd> <dt><img width=http://www.likecs.com/"20" height=http://www.likecs.com/"20" src=http://www.likecs.com/"{{ MEDIA_URL }}{{ request.user.image }}"/></dt> </dl> <div class=http://www.likecs.com/"userdetail"> <dl> <dt><img width=http://www.likecs.com/"80" height=http://www.likecs.com/"80" src=http://www.likecs.com/"{{ MEDIA_URL }}{{ request.user.image }}"/></dt> <dd> <h2>{{ request.user.nick_name }}</h2> <p>{{ request.user.username }}</p> </dd> </dl> <div class=http://www.likecs.com/"btn"> <a class=http://www.likecs.com/"personcenter fl" href=http://www.likecs.com/"{% url "users:user_info" %}">进入个人中心</a> <a class=http://www.likecs.com/"fr" href=http://www.likecs.com/"/logout/">退出</a> </div> </div> </div> <a href=http://www.likecs.com/"usercenter-message.html"> <div class=http://www.likecs.com/"msg-num"><span id=http://www.likecs.com/"MsgNum">0</span></div> </a> {% else %} <a style=http://www.likecs.com/"color:white" class=http://www.likecs.com/"fr registerbtn" href=http://www.likecs.com/"register.html">注册</a> <a style=http://www.likecs.com/"color:white" class=http://www.likecs.com/"fr loginbtn" href=http://www.likecs.com/"login.html">登录</a> {% endif %}