我建立了一个名为"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'),
)
Run Code Online (Sandbox Code Playgroud)
我的views.py是:
from django.views import generic
class WelcomeView(generic.TemplateView):
template_name = 'templates/welcome.html'
Run Code Online (Sandbox Code Playgroud)
目录结构是
+/home/mysite
- manage.py
- static
+ mysite
- views.py
- urls.py
- settings.py
- __init__.py
+ templates
- welcome.html
Run Code Online (Sandbox Code Playgroud)
当我跑:
python manage.py runserver
Run Code Online (Sandbox Code Playgroud)
我的浏览器说:"TemplateDoesNotExist at templates/welcome.html".有人可以帮帮我吗?非常感谢 !
小智 6
确保你已经把mysite你INSTALLED_APPS的settings.py,
INSTALLED_APPS = (
'mysite',
# ...... the rest of installed apps
)
Run Code Online (Sandbox Code Playgroud)