django创建第一个视图
新建项目的根目录里面创建一个view.py文件,然后输入代码
from django.http import HttpResponse def hello(request): return HttpResponse("Hello, world.")
接着去urls.py文件里加入以下代码
from django.conf.urls import url from . import view urlpatterns = [ url(r'^$', view.hello), ]
修改urls.py文件代码
from django.contrib import admin from django.conf.urls import url from django.urls import include, path from .import view urlpatterns = [ url(r'^$', view.hello), path('polls/', include('polls.urls')), path('admin/', admin.site.urls), ]
------此时淌的哈喇子,将成为明天的眼泪!