0

所以我是Django的新手,目前正嘗試在我的應用中構建註冊。我已經遵循這個guide。然而,我遇到了一個問題,即應用程序無法以某種方式找到該模板。TemplateDoesNotExist at/accounts/register/Error

Traceback: 

文件 「/usr/local/lib/python3.5/site-packages/django/core/handlers/exception.py」 在內 39.響應= get_response(請求)

文件 「/usr/local/lib/python3.5/site-packages/django/core/handlers/base.py」 在_get_response 217.響應= self.process_exception_by_middleware(E,請求)

文件 「/usr/local/lib/python3.5/site-packages/django/core/handlers/base.py」 在_get_response 215響應= response.render()

文件 「/ USR/local/lib目錄/ python3.5 /站點包/ Django的/模板/ response.py 「 在渲染 109 self.content = self.rendered_content

文件 」 在/ usr/local/lib目錄/ python3 .5/site-packages/django/template/response.py「 in rendered_content 84. template = self.resolve_template(self.template_name)

文件 「/usr/local/lib/python3.5/site-packages/django/template/response.py」 在resolve_template 66.返回select_template(模板,使用= self.using)

文件 「/usr/local/lib/python3.5/site-packages/django/template/loader.py」 在 select_template 53.加註TemplateDoesNotExist( ''。加入(template_name_list),鏈=鏈)

異常類型:TemplateDoesNotExist at/accounts/register/Exception Value:registration/registration_form.html

我已檢查以確保我的URL已設置,並且所有內容都應按順序排列。我花了過去2個小時尋找解決方案,沒有任何工作。

最讓我感動的是,在錯誤中,我可以看到它在哪裏檢查模板的確切位置,但我仍然看到該模板的實際路徑旁邊的以下內容。

(來源不存在)

請幫

+0

你確實有一個名爲'registration/registration_form.html'的模板嗎?該文件是否可以通過Web服務器wsgi進程讀取?你如何在'settings.py'中指定你的模板目錄? –

+0

是的,模板實際上在那裏,它是可讀的。我認爲這個問題與我的模板目錄有關,但作爲我的新手,我不知道我做錯了什麼。這是我的'settings.py'代碼如下。 'TEMPLATE_DIRS = [ os.path.join(BASE_DIR, '/帳號/註冊/'), os.path.join(BASE_DIR, '項目/模板/'), ]' – Kerosive

回答

0

請檢查您所定義TEMPLATES_DIRS正確

在Django中1。8以上:

TEMPLATES = [ 
    { 
     'DIRS': [ 
      # insert your TEMPLATE_DIRS here (absolute path) 
     ], 
    }, 
] 
+0

確保路徑是絕對的 – brunoelottero

+0

我正在使用Django的註冊,這是否仍然適用於使用這樣的包? – Kerosive

+0

是的,對於你打算把模板修改爲 – brunoelottero