我建立了一个名为“mysite”的
django项目.我的urls.py是
from django.conf.urls import patterns, include, url
from .views import WelcomeView
urlpatterns = patterns('',
url(r'^$', WelcomeView.as_view(), name='welcome'),
)
我的views.py是:
from django.views import generic
class WelcomeView(generic.TemplateView):
template_name = 'templates/welcome.html'
目录结构是
+/home/mysite
- manage.py
- static
+ mysite
- views.py
- urls.py
- settings.py
- __init__.py
+ templates
- welcome.html
当我跑:
python manage.py runserver
我的浏览器说:“TemplateDoesNotExist at templates / welcome.html”.有人可以帮帮我吗?非常感谢 !
最佳答案 确保你在settings.py的INSTALLED_APPS中放了mysite,
INSTALLED_APPS = (
'mysite',
# ...... the rest of installed apps
)