新建一个本地输入
python3 pyshop/manage.py startapp products
会创建一个package
要把项目包改一下,移动成这样
输入
python3 manage.py runserver
先打开网址
修改/添加代码
from django.http import HttpResponse
from django.shortcuts import render
def index(request):
return HttpResponse('Hello World')
pyshop/urls
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('products/', include('products.urls'))
]
products/urls.py
from django.urls import path
from products import views
urlpatterns = [
path('', views.index)
]
打开运行的网址:输入
出现上图则成功,返回主页面显示这样是正常的!