So I have develop a web site by django, everything works fine now. But I want to make one post that are protected by password which means you need to put in password to view the content of post. I search the internet and really didn't found a way to do that, some suggested hard code in post with password. I want more dynamic where you can edit in you admin post page with password protect option. similar to question here .
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'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.