python - Django-allauth 加载错误的 base.html 模板

标签 python django django-allauth

我已经尝试让 django-allauth 工作几天了,我终于知道发生了什么。

该应用程序没有加载随 django-allauth 安装的 base.html 模板,而是加载了我用于网站其余部分的 base.html 文件。

我如何告诉 django-allauth 使用 virtualenv/lib/python2.7/sitepackages/django-allauth 目录中的 base.html 模板而不是我的 project/template 目录?

最佳答案

我遇到了相反的问题:我试图使用我自己的 base.html 文件,但我的 Django 项目正在获取 django-allauth 版本base.html。事实证明,您在 settings.py 中定义 INSTALLED_APPS 的顺序会影响模板的呈现方式。为了让 my base.html 渲染而不是 django-allauth 中定义的渲染,我需要定义 INSTALLED_APPS如下:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # custom
    'common',
    'users',
    'app',
    # allauth
    'django.contrib.sites',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
]

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static'),
]

关于python - Django-allauth 加载错误的 base.html 模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16526314/

相关文章:

python - 向 django-allauth 的 OAuth token 添加权限

使用 allauth 进行 Django 测试

python - 如何解析 orderedDict?

ios - Django服务器没有从ios接收到授权 token - React native

python - 如何管理django中的锁写机制

django - 如何要求 Django 多关系管理器同时匹配多个关系?

python - 如何在 django-allauth 中设置用户密码的最小字符数

python - 区别 - tf.gradients 与 tf.keras.backend.gradients

python - 如何将箱线图叠加在 Seaborn 的群图之上?

python - gui应用程序的面向对象设计问题