自学内容网 自学内容网

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')


原文地址:https://blog.csdn.net/m0_74370400/article/details/143983682

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!