In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "the solution to the failure of check_password verification in django2.2.6". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Add custom authentication CustomBackend (mailbox, mobile phone number, etc.) to python3.6, django 2.2.6 AUTHENTICATION_BACKENDS
The password of a Super Admin created with python manage.py createsuperuser always fails to verify when logging in (False)
#.\ apps\ users\ backends\ other.py
#! / usr/bin/env python3#-*-coding: utf-8-*-"" @ author: yinzhuoqun@site: http://zhuoqun.info/@email: yin@zhuoqun.info@time: 18:06 on 2019-10-16 "from django.contrib.auth import get_user_modelfrom django.contrib.auth.backends import ModelBackendfrom django.db.models import Qfrom django.contrib.auth.hashers import check_passwordfrom apps.users.models import UserProfileUser = get_user_model () # user A unique value field other than the name can also be used to log in Setting should have corresponding configuration AUTHENTICATION_BACKENDSclass CustomBackend (ModelBackend): def authenticate (self, request, username=None, password=None, * * kwargs): try: # login user = UserProfile.objects.get (Q (username=username) | Q (email=username) | Q (phone=username)) # user_check_password = user.check_password (password) user_check_password = check_password (password) User.password) if user_check_password: return user except User.DoesNotExist: return None
Copy
# settings.py
AUTH_USER_MODEL = 'users.UserProfile' # users of the reloaded system Let UserProfile take effect # AUTH method (login of mailbox, mobile phone number, etc.), and verify that AUTHENTICATION_BACKENDS = ('apps.users.backends.other.CustomBackend', #' social_core.backends.weibo.WeiboOAuth3', # 'social_core.backends.qq.QQOAuth3', #' social_core.backends.weixin.WeixinOAuth3', # 'social_core.backends.github.GithubOAuth3', #' social_core.backends.gitlab.GitLabOAuth3') from top to bottom # 'django.contrib.auth.backends.ModelBackend',)
Copy
Delete the library to rebuild countless times can not, suddenly thought of using shell to reset the password once, sure enough, logged on.
(tracbug).\ tracbug > python manage.py shellPython 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32Type "help", "copyright" "credits" or "license" for more information. (InteractiveConsole) > > from django.contrib.auth import get_user_model > User = get_user_model () > user = User.objects.get (username= "yinzhuoqun") > > user > user.username'yinzhuoqun' > user.set_password ("xxxxxxxx") > user.save () "the solution to check_password Verification failure in django2.2.6" ends here. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.