繁体   English   中英

如何创建受密码保护的帖子页面

[英]how to create a password protected post page

所以我通过 django 开发了一个 web 站点,现在一切正常。 但是我想发一篇受密码保护的帖子,这意味着您需要输入密码才能查看帖子的内容。 我在互联网上搜索并真的没有找到一种方法来做到这一点,一些建议在帖子中使用密码的硬代码。 我想要更多动态,您可以在其中使用密码保护选项在管理帖子页面中进行编辑。 类似于这里的问题。

def password_protected_post(request):
    if request.mothod == 'POST':
        form = passwordform(request.POST)
        if form.is_valid():
            password = form.cleaned_data['password']
            if password == my_password:
                 return 'the content you want to show'
    else:
       ....'show the passwordform'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM