- 构建项目
mkdir bysms && cd bysms
django-admin startproject config .
- config 包下的settings.py中编写如下
ALLOWED_HOSTS = ['127.0.0.1', 'localhost']
- 创建项目app
# 终端进入项目根路径,执行如下命令
python manage.py startapp sales
- sales 包下的views.py中编写如下
from django.http import HttpResponse
def listorders(request):
return HttpResponse("下面是系统中所有的订单信息。。。")
- config 包下的urls.py中编写如下
from django.contrib import admin
from django.urls import path
from sales.views import listorders
urlpatterns = [
path('admin/', admin.site.urls),
path('sales/orders/', listorders),
]
- 启动项目
python manage.py runserver 0.0.0.0:80
- 浏览器测试