- 論壇徽章:
- 0
|
今天出學(xué)Django,在工作目錄mysite下建了一個(gè)testapp的子目錄,想測(cè)試下,寫(xiě)了個(gè)hello.py:
from django.http import HttpResponse
def index(request):
return HttpResponse("hello,Django")
然后把urls改了一下:
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"^$","mysite.testapp.hello.index")
)
然后我在本地 http://localhost:8000/ 查看時(shí)
卻說(shuō)沒(méi)有testapp.hello這個(gè)模塊
我把hello.py提出來(lái)放到mysite下面后把urls里面的改成mysite.hello.index 就可以正常訪問(wèn)了
難道不能訪問(wèn)子目錄嗎?還是我那樣寫(xiě)不對(duì)?我看了下官方的 http://docs.djangoproject.com/en/dev/topics/http/urls/?from=olddocs 也沒(méi)看到相關(guān)介紹(或者是沒(méi)看到。。=。=)
請(qǐng)教高手指導(dǎo) |
|