1.打开终端,进入到django项目,创建APP应用:python manage.py startapp news
2.在settings.py中进行注册
3.在news下新建views.py,和urls.py。
views.py:
from django.shortcuts import render # Create your views here. from django.http HttpResponse def index(request): return HttpResponse("hello world")
urls.py:
from django.contrib admin from django.urls path from . views urlpatterns = [ path('',views.index),]
4.在myweb中的urls.py
path,include from news urls urlpatterns ='admin/'
5.启动服务
python manage.py runserver