【发布时间】:2011-02-19 23:16:49
【问题描述】:
这适用于运行 apache 版本 2.2.17 的 Wamp Server 上的 Django 1.2.5 和 Python 2.7。
我的问题是 urls.py 中的我的 URLConf 没有重定向,它只是抛出 404 错误。
urls.py:
from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
#from django.contrib import admin
#admin.autodiscover()
urlpatterns = patterns('',
(r'^app/$', include('app.views.index')),
# 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.http import HttpResponse
def index(request):
return HttpResponse("Hello World")
我收到以下错误: /app/ 处的 ImportError 没有名为 index 的模块
我只是在学习 Django,所以我很难过,有人能看出我的代码有什么问题吗?这是我的 PythonPath: ['C:\Windows\system32\python27.zip', 'C:\Python27\Lib', 'C:\Python27\DLLs', 'C:\Python27\Lib\lib-tk', 'C:\wamp \bin\apache\Apache2.2.17', 'C:\wamp\bin\apache\apache2.2.17\bin', 'C:\Python27', 'C:\Python27\lib\site-packages', 'c: \wamp\www\seetwo']
【问题讨论】: