用户系统
django-allauth
使用django-allauth(0.39.1)
安装
pip install django-allauth配置 settings.py (Important - Please note ‘django.contrib.sites’ is required as INSTALLED_APPS):
```python
Specify the context processors as follows:
TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [
# Already defined Django-related contexts here # `allauth` needs this from django 'django.template.context_processors.request', ], },}, ]
AUTHENTICATION_BACKENDS = ( ...
# Needed to login by username in Django admin, regardless of `allauth`
'django.contrib.auth.backends.ModelBackend',
# `allauth` specific authentication methods, such as login by e-mail
'allauth.account.auth_backends.AuthenticationBackend',
...)
INSTALLED_APPS = ( ...
)
SITE_ID = 1
############
allauth基本设定 #
############
ACCOUNT_AUTHENTICATION_METHOD = 'username_email' ACCOUNT_EMAIL_REQUIRED = True LOGIN_REDIRECT_URL = "/case"
ACCOUNT_SIGNUP_FORM_CLASS = 'users.forms.registions'
AUTHENTICATION_BACKENDS = ( 'allauth.account.auth_backends.AuthenticationBackend', 'django.contrib.auth.backends.ModelBackend', )
####################
django-auth登录地址设定 #
####################
LOGIN_URL="/users/login/" #?next=/
######
邮箱设定 #
######
EMAIL_HOST = "smtp.mail.com" EMAIL_PORT = 25 #QQ邮箱使用587 EMAIL_HOST_USER = "[email protected]" EMAIL_HOST_PASSWORD = "password" # 这个不是邮箱密码,而是授权码 EMAIL_USE_TLS = True # 这里必须是 True,否则发送不成功 EMAIL_FROM = "[email protected]" # 发件人 DEFAULT_FROM_EMAIL = "UNOECP [email protected]" # 默认发件人(如果不添加DEFAULT_FROM_EMAIL字段可能会导致如下错误: 451, b'Sender address format error.', 'webmaster@localhost')
数据库
python manage.py migrateallath没有用户资料修改功能,需要自己编写,可以扩展用户资料,相关问题想看代码本部分,在url中的配置参考以下
最后更新于
这有帮助吗?