1.在 myapp 目录下,新增一个urls.py文件,把新增的两个接口添加到路由

from django.conf.urls import url, include
from myapp import views
urlpatterns = [
url(r’add_person$’, views.add_person, ),
url(r’show_persons$’, views.show_persons, ),
]

2.我们还要把 app 下的urls.py添加到 App下的urls.py中,才能完成路由关联。

from django.contrib import admin
from django.urls import path
from django.conf.urls import url, include
import myapp.urls

urlpatterns = [
path(‘admin/’, admin.site.urls),
# url(r’^api/’, include(myapp.urls)),
url(r’^’, include(myapp.urls)),
]

Categories:

Tags:

No responses yet

发表评论

邮箱地址不会被公开。 必填项已用*标注