- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
所以我刚刚设置了我的 Digital Ocean droplet(服务器)并一直在努力让这个网站正常工作,但是我遇到了一个接一个的错误。我终于让网站加载了登录页面(这是应该发生的),但是当我登录时,我收到一个错误,Argon2 Pass Hasher 无法加载。我真的不知道问题出在哪里,因为在开发过程中一切正常。
这里是错误:
ValueError at /accounts/login/
Couldn't load 'Argon2PasswordHasher' algorithm library: No module named argon2
这是我的设置:
"""
Django settings for django_project project.
Generated by 'django-admin startproject' using Django 1.8.7.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TEMPLATE_DIR = os.path.join(BASE_DIR, 'templates')
MEDIA_DIR = os.path.join(BASE_DIR, 'media')
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'h&*(yq942_a^pa+ty&wh(bl9s4d#z^*_6cmeb#5&49jb^r$&!f'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'users',
'feed',
'blog',
'allauth',
'allauth.account',
'allauth.socialaccount',
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)
ROOT_URLCONF = 'django_project.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'django_project.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
PASSWORD_HASHERS = [
'django.contrib.auth.hashers.Argon2PasswordHasher',
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
'django.contrib.auth.hashers.BCryptPasswordHasher',
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
]
# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
SITE_ID = 1
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = '/static/'
STATIC_DIR = os.path.join(BASE_DIR,'static')
STATICFILES_DIRS = [
STATIC_DIR,
]
#MEDIA
MEDIA_ROOT = MEDIA_DIR
MEDIA_URL = '/media/'
LOGIN_URL = '/user_login'
# settings
ACCOUNT_AUTHENTICATION_METHOD = 'username_email'
ACCOUNT_USERNAME_REQUIRED = True
ACCOUNT_UNIQUE_USERNAME =True
ACCOUNT_SIGNUP_EMAIL_ENTER_TWICE =False
ACCOUNT_SIGNUP_PASSWORD_ENTER_TWICE =True
ACCOUNT_EMAIL_CONFIRMATION_EXPIRE_DAYS =3
ACCOUNT_LOGIN_ATTEMPTS_LIMIT = 5
ACCOUNT_LOGOUT_ON_PASSWORD_CHANGE =True
ACCOUNT_SESSION_REMEMBER =None
ACCOUNT_ADAPTER ='allauth.account.adapter.DefaultAccountAdapter'
ACCOUNT_UNIQUE_EMAIL =True
# SOCIALACCOUNT_AUTO_SIGNUP =True
# SOCIALACCOUNT_EMAIL_REQUIRED ='ACCOUNT_EMAIL_REQUIRED'
# SOCIALACCOUNT_QUERY_EMAIL ='ACCOUNT_EMAIL_REQUIRED'
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_CONFIRMATION_HMAC =True
ACCOUNT_EMAIL_VERIFICATION = 'none'
#ACCOUNT_EMAIL_VERIFICATION = 'optional'
#ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.sendgrid.com'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_HOST_USER = 'username'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'support@yoursite.com'
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
# Allow Django from all hosts. This snippet is installed from
# /var/lib/digitalocean/allow_hosts.py
import os
import netifaces
# Find out what the IP addresses are at run time
# This is necessary because otherwise Gunicorn will reject the connections
def ip_addresses():
ip_list = []
for interface in netifaces.interfaces():
addrs = netifaces.ifaddresses(interface)
for x in (netifaces.AF_INET, netifaces.AF_INET6):
if x in addrs:
ip_list.append(addrs[x][0]['addr'])
return ip_list
# Discover our IP address
ALLOWED_HOSTS = ip_addresses()
这是回溯:
Traceback Switch to copy-and-paste view
/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py in inner
response = get_response(request) ...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py in _legacy_get_response
response = self._get_response(request) ...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py in _get_response
response = self.process_exception_by_middleware(e, request) ...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs) ...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py in view
return self.dispatch(request, *args, **kwargs) ...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py in _wrapper
return bound_func(*args, **kwargs) ...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/django/views/decorators/debug.py in sensitive_post_parameters_wrapper
return view(request, *args, **kwargs) ...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py in bound_func
return func.__get__(self, type(self))(*args2, **kwargs2) ...
▶ Local vars
/home/django/django_project/allauth/account/views.py in dispatch
return super(LoginView, self).dispatch(request, *args, **kwargs) ...
▶ Local vars
/home/django/django_project/allauth/account/views.py in dispatch
**kwargs) ...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py in dispatch
return handler(request, *args, **kwargs) ...
▶ Local vars
/home/django/django_project/allauth/account/views.py in post
if form.is_valid(): ...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/django/forms/forms.py in is_valid
return self.is_bound and not self.errors ...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/django/forms/forms.py in errors
self.full_clean() ...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/django/forms/forms.py in full_clean
self._clean_form() ...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/django/forms/forms.py in _clean_form
cleaned_data = self.clean() ...
▶ Local vars
/home/django/django_project/allauth/account/forms.py in clean
**credentials) ...
▶ Local vars
/home/django/django_project/allauth/account/adapter.py in authenticate
user = authenticate(request=request, **credentials) ...
▶ Local vars
/home/django/django_project/allauth/compat.py in authenticate
return authenticate(request=request, **credentials) ...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/django/contrib/auth/__init__.py in authenticate
user = _authenticate_with_backend(backend, backend_path, request, credentials) ...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/django/contrib/auth/__init__.py in _authenticate_with_backend
return backend.authenticate(*args, **credentials) ...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/django/contrib/auth/backends.py in authenticate
if user.check_password(password) and self.user_can_authenticate(user): ...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/django/contrib/auth/base_user.py in check_password
return check_password(raw_password, self.password, setter) ...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/django/contrib/auth/hashers.py in check_password
must_update = hasher_changed or preferred.must_update(encoded) ...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/django/contrib/auth/hashers.py in must_update
argon2 = self._load_library() ...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/django/contrib/auth/hashers.py in _load_library
(self.__class__.__name__, e)) ...
▶ Local vars
请帮忙,这个问题似乎很具体,所以我没能找到很多关于它的信息......
最佳答案
根据documentation :
很简单,我只需要在服务器上运行 pip install django[argon2]
,相当于 python -m pip install argon2-cffi
。
关于python - 现场生产中 argon2 hasher 的 Django 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46416985/
我刚接触一个项目,开发人员仍然通过邮件发送文件来共享代码。我们正在使用 eclipse 和 cvs。 场外的开发人员将代码发送到现场进行审核,其他开发人员从那里的邮件中一一获取文件并在 Eclipse
我完成了 session 站点设计,现在应该创建数据库。但我不确定该使用哪种方法。我正在使用 Apache、PHP 和 MySQL。我有用户,每个用户都有输入和输出邮箱,每个用户都有一个好友列表。这是
我们的开发团队刚刚将一个应用程序从本地服务器迁移到实时站点。该应用程序利用可写入的远程数据库,并利用 MSQLi 和 PDO 方法获取数据并将数据推送到数据库。 更新 connect .inc 文件以
大家好,我想使用 java 连接到我网站上的数据库。我想知道我应该在 URL 中输入什么: cnt=DriverManager.getConnection(DB_URL, DB_UID,DB_PWD)
我不确定“硬失败”是否是正确的词,但这是我面临的问题。我花了相当长的时间来重现这个尽可能最小的例子,所以它是这样的: class BaseParameterizedType fun > getSpec
我希望有人能够帮助解决我遇到的问题。下面的代码管理我正在开发的网站上的音频播放器。这个想法是,用户可以单击静音按钮来切换网站上的声音,如果用户单击特定链接离开网站,则声音应该被静音(如果尚未静音)。
我在站点中使用 libcurl 进行身份验证。我用它制作了很多功能,例如: char *CheckLoginPass(char *login, char *pass) { //use curl_e
我正在创建一个社交媒体风格的网站,并使用 Meteor 和 MongoDB 创建帖子,其中包含 {{title}} 和 {{content}}一个 Accordion 菜单,标题在菜单的标题上,内容在
我昨天为一个网站写了一个小的桌面 package 器(它实际上只是加载一个网站),作为对 Electron 的一些练习,但我注意到以下事情: 通常应该(并且确实)在每个浏览器上工作的 Javascri
我的应用程序中有 WebView 。我可以在 IDE 中看到警告。“使用 setJavaScriptEnabled 会引入 XSS 漏洞”代码 webView.getSettings().setJav
我正在做一个多步骤表单,所有内容都在最后保存。在我的模型中,我有一个 m2m 复选框字段,并且我使用 django Sessions 来获取表单数据以在最后一步中显示它。 问题是当我提交最终表单时,m
我们已经实现了 WURFL 现场 Java 应用程序(使用 maven/servlet 实现的 berryapp),我们将其用于所有 Java 应用程序,只需在所有其他应用程序中调用该应用程序即可。由
我是一名优秀的程序员,十分优秀!