2013-06-09 2 views
0

link의 지침을 사용해 기본 앱 템플릿을 내 웹 사이트의 템플릿으로 교체해 보았습니다. 나는 "files_with_same_name_as_userena_templates.html"의 내용을 변경 시도하고 웹 서버를 다시 시작할 때, 그러나Django Userena - 기본 django app 템플릿을 올바르게 덮어 씁니까?

TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". 
    # Always use forward slashes, even on Windows. 
    # Don't forget to use absolute paths, not relative paths. 
) 

:

project_specific_app 
-templates 
--userena 
---files_with_same_names_as_userena_templates.html 

TEMPLATE_DIRS :

특히, 나는 다음과 같은 파일 구조를 설정 한 , 웹 페이지가 변경되지 않음

내가 잊어 버린 것은 무엇입니까?

해결 방법 : 내 프로젝트/settings.py에서 TEMPLATE_DIRS을보고/absolute/path/to/project/특정/app/templates/내 사용자 정의 된 템플릿으로 변경했습니다.

+0

'settings.py '의'TEMPLATE_DIRS' 변수는 어떻게 생겼습니까? –

+0

TEMPLATE_DIRS = ( # "/ home/html/django_templates"또는 "C :/www/django/templates"와 같이 문자열을 넣으십시오 .. # Windows에서도 항상 슬래시를 사용하십시오. 절대 경로가 아닌 상대 경로 ) – landon

+0

질문에 답변을 게시해서는 안됩니다. 오히려 주어진 답을 받아들입니다. –

답변

2

settings.py에 정의 된 TEMPLATE_DIRS이 없기 때문일 수 있습니다. 이 그것을 수정 :

TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". 
    # Always use forward slashes, even on Windows. 
    # Don't forget to use absolute paths, not relative paths. 
    'full/path/to/your/templates/dir', 
    ) 

TIP : 일반적으로, 그것은 경로를 하드 코딩하지 않도록하는 것이 좋습니다. 당신은 템플릿 디렉토리의 전체 경로를 얻을 수 (또는 어떤 경로 필요) 및 휴대용 프로젝트를 유지하는 대신이 트릭을 수행 할 수 있습니다

import os 
settings_dir = os.path.dirname(__file__) 
PROJECT_ROOT = os.path.abspath(os.path.dirname(settings_dir)) 

... 

TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". 
    # Always use forward slashes, even on Windows. 
    # Don't forget to use absolute paths, not relative paths. 
    os.path.join(PROJECT_ROOT, 'templates/'), 
) 

희망이 도움이!

+0

해결책이 훌륭하게 작동했습니다. 감사합니다! – landon

+0

다행입니다. 천만에. 그것이 유용했다면 대답을 받아 들일 것을 고려하십시오 :) –

관련 문제