本章配套視頻教程:Python-Django手把手從零開發個人博客_哔哩哔哩_bilibili
一、在base中引入登錄注冊url,並判斷用戶是否登錄,顯示用戶名
{% if user.is_authenticated %}
<div class="buttons">
<a class="button is-primary" href="{% url 'users:user_profile' %}" target="_blank">
<strong> {
{ request.user.username }}</strong>
</a>
<a href="{% url 'users:logout' %}" class="button is-primary">退出</a>
</div>
{% else %}
<div class="buttons">
<a class="button is-primary" href="{% url 'users:register' %}" target="_blank">
<strong>注冊</strong>
</a>
<a class="button is-light" href="{% url 'user