[其他] 请教一个关于django出现404的问题(急)

Richmond1979 2011-05-25

按照django book上面写了个很简单到页面:
views.py:
from django.http import HttpResponse
import datetime

def current_datetime(request):
now = datetime.datetime.now()
html = "<html><body>It is now %s.</body></html>" % now
return HttpResponse(html)

urls.py:
from django.conf.urls.defaults import *
from djangotest.views import current_datetime
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('',
(r'^time/$', current_datetime),
)

在浏览器输入http://127.0.0.1:8000/djangotest/time/
页面出现...
Using the URLconf defined in djangotest.urls, Django tried these URL patterns, in this order:

1. ^time/$

The current URL, djangotest/time/, didn't match any of these.
...

哪位高手可以告诉我究竟是什么原因呢,纠结死了~

allenjiang 2011-05-30
url(r'^time/$', current_datetime),
而且应该是http://127.0.0.1:8000/time/
Global site tag (gtag.js) - Google Analytics