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

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

问题描述

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

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. 编辑'DIRS' settings.py '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')],

最终应该看起来像这样:

At 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 / * ,bec一旦软件包更新,所有更改都将丢失。

  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天全站免登陆