问题描述
尝试加载网站时出现``找不到页面''错误。(127.0.0.1:8000/catalog/)
这是我的urls.py
urlpatterns = patterns('',
(r'^catalog/$', 'preview.views.home'),
# Example:
# (r'^ecomstore/', include('ecomstore.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
# (r'^admin/', include(admin.site.urls)),
)
在包中预览我的views.py
from django.shortcuts import render_to_response
# Create your views here.
def home(request):
return render_to_response("index.html")
“ index.html”位于ecomstore / templates文件夹中,变量TEMPLATE_DIRS设置为此目录。
奇怪的是,我没有调试跟踪,但是DEBUG变量设置为true有人知道怎么了吗?
1楼
我遇到了这个问题,因为我在index.html中将I大写了。 因此,它正在寻找index.html,而我拥有Index.html。 花了我一个小时找到那个。 只是仔细检查。
2楼
在settings.py
,您的TEMPLATE_DIRS
是什么样子?您希望index.html
在磁盘上的加载和呈现路径是什么?
听起来好像它正在尝试查找index.html
但找不到它,但是如果没有调试回溯,很难说清楚。
3楼
作为一种解决方法,也许您可??以尝试
今天早上,我在Windows XP计算机上遇到了同样的情况。 当我从使用127.0.0.1切换到localhost时,它才开始工作。 我仍然不知道该怎么做才能使其停止工作。
4楼
这是您的根(项目级)URLconf,还是来自您的一个应用程序? 如果来自您的一个应用程序,是否正确包含在根URLconf中?
我问,因为如果Django确实正在读取它,那么您显示的代码应该可以工作。
另一个想法:该视图中是否引发了Http404异常?
是直接还是通过get_object_or_404
?
我还同意上面的请求以共享完整的回溯。