# -*- coding: utf-8 -*- # @File : urls.py # @Author :WeiSanJin # @Time :2021/04/06 21:39 # @Site :https://github.com/WeiSanJin from django.conf.urls import url from apps.organizations.views import OrgView, AddAskView, OrgHomeView, OrgTeacherView, OrgCourseView, OrgDescView from apps.organizations.views import TeacherListView, TeacherDetailView urlpatterns = [ url(r'^list/$', OrgView.as_view(), name="list"), url(r'^add_ask/$', AddAskView.as_view(), name="add_ask"), # path('<intt:org_id>/', OrgHomeView.as_view(), name="home") url(r'^(?P<org_id>\d+)/$', OrgHomeView.as_view(), name="home"), url(r'^teacher/(?P<org_id>\d+)/$', OrgTeacherView.as_view(), name="teacher"), url(r'^course/(?P<org_id>\d+)/$', OrgCourseView.as_view(), name="course"), url(r'^desc/(?P<org_id>\d+)/$', OrgDescView.as_view(), name="desc"), # 讲师列表页 url(r'^teachers/$', TeacherListView.as_view(), name="teachers"), # 讲师详情页 url(r'^teachers/(?P<teacher_id>\d+)/$', TeacherDetailView.as_view(), name="teacher_detail"), ]
#配置上传文件的访问url url(r'^media/(?P<path>.*)$', serve, {"document_root": MEDIA_ROOT}), # url(r'^static/(?P<path>.*)$', serve, {"document_root":STATIC_ROOT}), #机构相关页面 url(r'^org/', include(('apps.organizations.urls', "organizations"), namespace="org")), #机构相关页面 url(r'^course/', include(('apps.courses.urls', "courses"), namespace="course")), #讲师相关页面 url(r'^teachers/(?P<teacher_id>\d+)/$', TeacherDetailView.as_view(), name="teacher_detail"), #用户相关操作 url(r'^op/', include(('apps.operations.urls', "operations"), namespace="op")), #个人中心 url(r'^users/', include(('apps.users.urls', "users"), namespace="users")), #配置富文本相关的url url(r'^ueditor/', include('DjangoUeditor.urls')), ] #1. CBV(class base view) FBV(function base view)
from django.urls import path from apps.organizations.views import OrgView,AddAskView,OrgHomeView,OrgTeacherView,OrgCourseView,OrgDescView,TeacherView,TeacherDetailView urlpatterns = [ path("list/", OrgView.as_view(), name="list"), path("add_ask/", AddAskView.as_view(), name="add_ask"), path("<int:org_id>/", OrgHomeView.as_view(), name="home"), path("<int:org_id>/teacher/", OrgTeacherView.as_view(), name="teacher"), path("<int:org_id>/course/", OrgCourseView.as_view(), name="course"), path("<int:org_id>/desc/", OrgDescView.as_view(), name="desc"), path("teachers/", TeacherView.as_view(), name="teachers"), path("teachers/<int:teacher_id>/", TeacherDetailView.as_view(), name="detail"), # namespace是用于在下一个其内部的name前面添加namespace,在URL中,使用url:list进行定位 ]