在 mysite 站点下,创建 polls ,并注册了 polls。
#python manage.py runserver 0.0.0.0:80
vim polls/urls.py
from django.conf.urls import patterns, url
from polls import views
urlpatterns = patterns('',
url(r'^$',views.index, name='index')
)
vim polls/views.py
from django.http import HttpResponse
def index(request):
return HttpResponse("hello,you are the poll index.")
在mysite下, vim urls.py
from django.conf.urls.defaults import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^polls/', include('polls.urls')),
url(r'^admin/', include(admin.site.urls)),
)
打开
ImportError at /polls
cannot import name patterns
解决办法:vim polls/urls.py
将 from django.conf.urls import patterns, url
改为 from django.conf.urls.defaults import *
即可出现:hello,you are the poll index.
阅读(10350) | 评论(0) | 转发(0) |