示例#1
0
from app.views import PostList, PostDetail, CategoryList, CategoryDetail
from django.urls import path

app_name = 'app'
urlpatterns = [
    path('', PostList.as_view(), name='post-list'),
    path('<int:pk>', PostDetail.as_view(), name='post-detail'),
    path('categories/', CategoryList.as_view(), name='category-list'),
    path('categories/<int:pk>', CategoryDetail.as_view(), name='category-detail'),
]
示例#2
0
from app.views import \
        PostList, PostDetail, \
        CategoryList, CategoryDetail, \
        AuthorList, AuthorDetail
from django.urls import path

app_name = 'app'
urlpatterns = [
    path('', PostList.as_view(), name='post-list'),
    path('<int:pk>', PostDetail.as_view(), name='post-detail'),
    path('categories/', CategoryList.as_view(), name='category-list'),
    path('categories/<int:pk>',
         CategoryDetail.as_view(),
         name='category-detail'),
    path('authors/', AuthorList.as_view(), name='author-list'),
    path('authors/<int:pk>', AuthorDetail.as_view(), name='author-detail'),
]
示例#3
0
文件: urls.py 项目: Larisa1992/D9-API
from app.views import PostList
from django.urls import path
from app.views import PostList, PostDetail
from app.views import CategoryList, CategoryDetail, index

app_name = 'app'
urlpatterns = [
    path('posts/', PostList.as_view(), name='post-list'),
    path('posts/<int:pk>', PostDetail.as_view(), name='post-detail'),
    path('categories/', CategoryList.as_view(), name='categories-list'), # все категории
    path('categories/<int:pk>', CategoryDetail.as_view(), name='categories-detail'), # единичная категория
]