我一直在尝试设置 django,以便开始学习它。但我什至无法显示一个简单的视图。这是我的文件结构:
âââ __init__.py
âââ __init__.pyc
âââ manage.py
âââ media
âââ pages
â  âââ views.py
âââ settings.py
âââ settings.pyc
âââ templates
â  âââ base.html
â  âââ home.html
âââ urls.py
âââ urls.pyc
抱歉,奇怪的符号,这就是 linux 计算机使用 tree 命令打印出来的方式。这是我的网址文件:
from django.conf.urls.defaults import patterns, include, url
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
url(r'^$', 'testsite.pages.views.home', name='home'),
# url(r'^testsite/', include('testsite.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls))
)
基本上,我希望 example.com 指向 pages.views.home 视图。但它找不到它并不断给我错误:Could not import testsite.pages.views. Error was: No module named pages.views
我对 python 和 django 都是新手,所以我可能正在做一些简单得愚蠢的事情。提前致谢!