Django的Allauth注册模板 [英] Templates in Allauth registration for Django
问题描述
¿我如何编辑/修复登录页面的Allauth模板到Django 1.8?
我一直在阅读有关导览,我没有找到任何解决问题的人
这是我的settings.py
为colectr项目的Django设置
使用Django 1.8.3生成'django-admin startproject'
有关此文件的更多信息,请参阅
https://docs.djangoproject.com/en/1.8/topics/settings/
有关设置及其值的完整列表,请参阅
https://docs.djangoproject .com / en / 1.8 / ref / settings /
#在项目中构建路径,如下所示:os.path.join(BASE_DIR,...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__ file__)))
#启动开发设置 - 不适合生产
#请参阅https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
#安全警告:保留密钥用于生产秘密!
SECRET_KEY ='_j& ok $ + 7xf3-y $ hjz * 7461xxq!qm8dj6 ^)!7 ^ s2fov(ue3kdrq'
#安全警告:不要运行调试打开在生产!
DEBUG = True
ALLOWED_HOSTS = []
#Requerido por django.contrib.sites
SITE_ID = 1
#应用程序定义
INSTALLED_APPS =(
#需要Django网站框架
'django.contrib.sites',
'django.contrib.admin ',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages'
'django.contrib.staticfiles',
#Django-allauth的应用程序
'allauth',
'allauth.account ',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers .tumblr',
'allauth.so cialaccount.providers.amazon',
#自己的应用程序
'stock',
)
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 ='colectr.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',
#allauth特定的上下文处理器
#allauth.account.context_processors.account,
#allauth.socialaccount.context_processors.socialaccount,
' django.template.context_processors.request',
],
},
},
]
WSGI_APPLICATION ='colectr.wsgi.application'
#数据库
#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'),
}
}
#国际化离子
#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
#Added
AUTHENTICATION_BACKENDS =(
#需要通过用户名登录Django管理员,不管`allauth`
django.contrib.auth.backends.ModelBackend,
# `allauth`具体的认证方法,如通过电子邮件登录
allauth.account.auth_backends.AuthenticationBackend,
)
#静态文件(CSS ,JavaScript,Images)
#https://docs.djangoproject.com/en/1.8/howto/static-files/
STATIC_URL ='/ static /'
这是我的结构
环境/ colectr / colectr / django-allauth
,
在从git获取文件之前,我获得了allauth(pip install)的pypi文件。
我建议您在项目根目录下创建一个项目模板目录。
然后,您可以修改 TEMPLATES
这样的变量:
从os.path import join,normpath
TEMPLATES = [
{
'BACKEND':'django.template.backends.django.DjangoTemplates',
'DIRS':[
normpath(join(BASE_DIR,'templates') )
],
'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',
'django.template.context_processors.request',
],
},
},
]
然后,您将需要创建文件夹帐户,并在其中创建一个login.html文件以覆盖allauth模板。
希望它有帮助,
¿How can i edit/fix the Allauth templates for login pages into Django 1.8?
I been reading about guides around and i don't find anything who resolves that.
This is my settings.py
"""
Django settings for colectr project.
Generated by 'django-admin startproject' using Django 1.8.3.
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__)))
# 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 = '_j&ok$+7xf3-y$hjz*7461xxq!qm8dj6^)!7^s2fov(ue3kdrq'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Requerido por django.contrib.sites
SITE_ID = 1
# Application definition
INSTALLED_APPS = (
# The Django sites framework is required
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# Apps for Django-allauth
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.tumblr',
'allauth.socialaccount.providers.amazon',
# Own Apps
'stock',
)
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 = 'colectr.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',
# allauth specific context processors
#"allauth.account.context_processors.account",
#"allauth.socialaccount.context_processors.socialaccount",
'django.template.context_processors.request',
],
},
},
]
WSGI_APPLICATION = 'colectr.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'),
}
}
# 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
#Added
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",
)
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/
STATIC_URL = '/static/'
Also this is my structure
environment/colectr/colectr/django-allauth
,
Before take the files from git i got the pypi files for allauth(pip install).
I recommend you to create a project templates directory on the root of your project.
Then you can modify your TEMPLATES
variable like this:
from os.path import join, normpath
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
normpath(join(BASE_DIR, 'templates')),
],
'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',
'django.template.context_processors.request',
],
},
},
]
Then, you will need to create the folder accounts and inside of it create a login.html file to override allauth templates.
Hope it helps,
这篇关于Django的Allauth注册模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!