一、编写前台界面views:
-
编写前台界面需要显示的内容,打开polls/views.py,编写如下代码:
polls/views.py
from django.http importHttpResponse
def index(request):
return HttpResponse("Hello, world. You're atthe polls index.")
-
编写自己应用的urls文件,在应用polls下创建urls.py,添加如下代码:
polls/urls.py
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.index, name='index'),
]
-
在项目的urls文件里指定自己应用的urls文件,打开项目的urls.py,添加如下代码:
mysite/urls.py