如何编辑 django-allauth 默认模板? [英] How to edit django-allauth default templates?

查看:22
本文介绍了如何编辑 django-allauth 默认模板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Django 1.10,我想将 allauth 的应用程序添加到我的网站,用于登录、登录等.我已经从 pip 安装了 allauth,并尝试将 allauth 存储库中的模板放入我的模板文件夹中并调用它们,但我不知道如何使其工作.

i'm using Django 1.10 and i want to add the allauth's app for login, signin, etc, to my website. I've installed allauth from pip, and tried to put the templates from allauth repository inside my templates folder and call them but i don't know how to make it work.

推荐答案

可以在这里找到正确答案:https://stackoverflow.com/a/31282443/4992248

The correct answer can be found here: https://stackoverflow.com/a/31282443/4992248

  1. 创建 yourproject/templates/allauth/account/ 并将您需要从 /myproject/Lib/site-packages/allauth/templates/account 编辑的所有模板粘贴到此处.
  1. Create yourproject/templates/allauth/account/ and paste here all templates you need to edit from /myproject/Lib/site-packages/allauth/templates/account.

如果您需要对 socialaccount 模板进行更改,请同时创建 yourproject/templates/allauth/socialaccount/

If you need to make changes for socialaccount templates, create also yourproject/templates/allauth/socialaccount/

  1. settings.py 中编辑 'DIRS''DIRS': [os.path.join(BASE_DIR, 'templates'), os.path.join(BASE_DIR, 'templates', 'allauth')],
  1. Edit 'DIRS' in settings.py like 'DIRS': [os.path.join(BASE_DIR, 'templates'), os.path.join(BASE_DIR, 'templates', 'allauth')],

最后它应该看起来像这样:

In the end it should look somethink like this:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates'), os.path.join(BASE_DIR, 'templates', 'allauth')],
        'APP_DIRS': True,
        'OPTIONS': {
            'debug': False,
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.template.context_processors.media',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

  1. 您永远不应该在 /Lib/site-packages/* 中进行任何代码更改,因为一旦更新包,所有更改都会丢失.
  1. You never should do any code changes at /Lib/site-packages/*, because all changes are lost once a package is updated.

这篇关于如何编辑 django-allauth 默认模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆