2016-07-31 132 views
0

我正在使用django-registration-redux並希望更改模板的樣式。爲此,我從github中獲取模板/註冊文件夾,並將其添加到包含模板的文件夾中。如何告訴我的項目文件夾中的Django搜索模板更改django模板路徑

D:\django\blogRodion\blogRodion\blog\templates\registration\ 

,而不是

D:\django\blogRodion\blogRodion\env\lib\site-packages\registration\templates\registration\ 
+0

你可以把你的'註冊'放在'django.contrib.admin'上面嗎? –

回答

0

添加下面的代碼在你的settings.py Django的(1.8+)

import os 

BASE_DIR = os.path.dirname(os.path.dirname(__file__)) 

TEMPLATES = [ 
    { 
    'BACKEND': 'django.template.backends.django.DjangoTemplates', 
    'DIRS': [ 
     os.path.join(BASE_DIR, 'templates'), 
     'other_dir_path_to_include' 
    ], 
    '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', 
     ], 
    }, 
    }, 
] 

詳細內容見:https://docs.djangoproject.com/en/1.9/ref/settings/#std:setting-TEMPLATE_DIRS

+0

這不適合我。我是jast覆蓋源文件夾。 – Rodion

+0

在項目的根級創建一個名爲「模板」的文件夾,並在其中保留模板。它會工作。 –

+0

這項工作:'DIRS':[ os.path.join(BASE_DIR,'blog \\ templates'), ], – Rodion