Bootstrap

django+boostrap实现发布博客权限控制

一、修改base.html的控件链接

<a href="/" class="d-flex align-items-center mb-2 mb-lg-0 text-white text-decoration-none">
                <img src="{% static 'image/OIP-C.jpg' %}" alt="" height="40">
            </a>

            <ul class="nav col-12 col-lg-auto me-lg-auto mb-2 justify-content-center mb-md-0">
                <li><a href="/" class="nav-link px-2 text-secondary">主页</a></li>
                <li><a href="{% url 'blog:pub_blog' %}" class="nav-link px-2 text-secondary">发布博客</a></li>

            </ul>

二、发布博客必须先登录

from django.urls.base import reverse_lazy
@login_required(login_url=reverse_lazy("cwauth:login"))
def pub_blog(request):
    return render(request,'pub_blog.html')

;