2017-06-13 43 views
1

enter image description here我正在通過django中的custum模板處理其他密碼,但是自定義模板沒有加載它,每當我加載/ password_reset/url時都會加載django的默認模板。在密碼重置視圖自定義模板不加載?

我使用的URL

url('^', include('django.contrib.auth.urls')), 

我在模板的註冊文件夾,並使用這個鏈接工作 https://simpleisbetterthancomplex.com/tutorial/2016/09/19/how-to-create-password-reset-view.html

和模板文件夾是:

TEMPLATES = [ 
    { 
     'BACKEND': 'django.template.backends.django.DjangoTemplates', 
     'DIRS': [os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 
       ], 

     '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', 
       "cms.utils.context_processors.permission_based_hidding_of_sidebar", 
      ], 
      'libraries':{ 
       'template_tag': 'cms.templatetags.template_tag', 
       'template_tag_time': 'cms.templatetags.tags', 
      } 
     }, 
    }, 
] 

安裝應用程序在設置中: -

INSTALLED_APPS = [ 
    'cms', 
    'django.contrib.contenttypes', 
    'django.contrib.sessions', 
    'django.contrib.messages', 
    'django.contrib.staticfiles', 
    'django_extensions', 
    'django_csv_exports', 
    'django.contrib.auth', 
    'django.contrib.admin', 


] 
+0

你有沒有建立在你的目錄'password_reset'模板文件? –

+0

是的,我在我的模板中有一個註冊文件夾,我已經創建了password_reset.html模板 –

+0

您可以在您的問題中包含您的項目結構嗎?我也想知道你的註冊文件夾在哪裏? –

回答

0

如果您想要覆蓋Django管理員模板,您需要在templates目錄內創建admin文件夾。而將所有的管理員的文件和文件夾有...

templates 
|__ admin 
    |__ registration 

更新:也請更正模板DIR應該

'DIRS': [os.path.join(BASE_DIR, 'templates')], 
+0

放置您的所有管理文件意味着我想覆蓋或所有文件,因爲我想覆蓋的那個我把它放在管理面板,它不工作。 –

+0

您需要覆蓋註冊模板的權利。因此,在'templates'中創建一個名爲'admin'的文件夾並放置註冊文件夾... –

+0

但它仍然顯示Django模板..不是自定義模板 –

相關問題