Skip to content

1、在自定义app目录里新建urls.py文件,文件内容如下

# -*- coding: utf-8 -*-
"""
@Remark: 地区地址相关的路由文件
"""
from django.urls import path, re_path
from rest_framework import routers

from apps.address.views import AreaViewSet

system_url = routers.SimpleRouter()
system_url.register(r'area', AreaViewSet)

urlpatterns = [
    re_path('area_root/', AreaViewSet.as_view({'get': 'area_root'})),
]
urlpatterns += system_url.urls

2、在application的urls.py文件中

在 【管理后台的标准接口】注释中新增该url供前端访问调用

path('api/address/', include('apps.address.urls')),

此时会自动生成/api/address/

get:     查询
post:    新增
put:     修改
delete:  删除

Released under the Apache License 2.0