documentation에 따르면 django는 앱의 루트 디렉토리에 'templates'라는 폴더가 있으면 내 앱에서 자동으로 템플릿을로드해야합니다.django에서 템플릿 자동로드가 작동하지 않습니다.
나는
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
# 'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'django.contrib.admindocs',
# Use email as username https://github.com/dabapps/django-email-as-username
'emailusernames',
'purchaseapp' # this is my app
)
가 나는 템플릿 폴더
을 만든 내가 로그인 페이지
로 관리자를 사용하도록 설정 urlpatterns을했습니다 내 응용 프로그램 추가 한urlpatterns = patterns('',
# Examples:
# url(r'^$', 'timely.views.home', name='home'),
# url(r'^timely/', include('timely.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
url(r'^$', hello),
url(r'^accounts/logout/$', 'django.contrib.auth.views.logout'),
url(r'^accounts/login/$', 'django.contrib.auth.views.login', {'template_name': 'admin/login.html'}),
url(r'^accounts/$', 'django.views.generic.simple.redirect_to', {'url': '/'}),
url(r'^accounts/profile/$', 'django.views.generic.simple.redirect_to', {'url': '/'}),
)
내가 base_site.html을 덮어 썼지 만 내 사용자 정의가 표시되지 않습니다. wh 내가 TEMPLATE_DIRS에 폴더를 추가하는지 확인합니다
TEMPLATE_DIRS = (
"/Users/nicola/Documents/Aptana Studio 3 Workspace/timely/purchaseapp/templates",
# 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.
)
무엇이 잘못 되었나요?
BTW 들어있는 contrib 관리자보다 먼저 와야했습니다 정지하기 때문에 어쩌면 당신이 django.template.loaders를 추가 할 것입니다, 검색 장고이었다 .app_directories.loader를 템플릿 로더에로드하여 TEMPLATE_DIRS에서 템플릿을 선택하지 않고 앱에서 템플릿을로드 할 수 있습니다. – simplylizz
프로젝트 폴더의 루트에 템플릿 폴더를 추가하고 응용 프로그램 폴더에 비슷한 문제가 발생하여 문제가 해결되었습니다. – vedarthk
@simplylizz 아니, 이미 제안을 주셔서 감사합니다. –