1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.conf.urls import url, include 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """ from django.conf.urls import url, include from django.contrib import admin from django.views.generic import TemplateView # TemplateView可以不用自己写跳转view也可以完成跳转 from apps.users.views import LoginView, RegisterView, ActiveUserView, ForgetPwdView, ResetView, ModifyOowdView import xadmin # TemplateView自带的view不用自己写跳转view也可以完成跳转 urlpatterns = [ url(r'^admin/', xadmin.site.urls), url('^$', TemplateView.as_view(template_name="index.html"), name='index'), # 使用django自带的TemplateView做跳转 # url('^login/$', LoginView, name='login'), # 自己写的跳转 url('^login/$', LoginView.as_view(), name='login'), # 登陆 url('^register/$', RegisterView.as_view(), name='register'), # 注册 url(r'^captcha/', include('captcha.urls')), # 验证码 # 邮箱激活,解析出url aactive 后面为了验证生成的乱码, 这里<>可以随意写后面要用这个名字调用, 使用正则表达式解析的 url(r'^active/(?P<active_code>.*)/$', ActiveUserView.as_view(), name="user_active"), url(r'^forget/$', ForgetPwdView.as_view(), name='forget_pwd'), url(r'^reset/(?P<active_code>.*)/$', ResetView.as_view(), name="reset_pwd"), url(r'^modify_pwd/$', ModifyOowdView.as_view(), name='modify_pwd'), ]
# ,STATIC_ROOT from apps.users.views import IndexView # from django.conf.urls import handler404, handler500 urlpatterns = [ path('xadmin/', xadmin.site.urls), # path('center/', UserCenterView.as_view(), name='user_center'), path('', IndexView.as_view(), name="index"), path('login/', LoginViews.as_view(), name="login"), path('logout/', LogoutViews.as_view(), name="logout"), path('register/', RegisterViews.as_view(), name="register"), path('captcha/', include('captcha.urls')), re_path('active/(?P<active_code>.*)/', ActiveUserView.as_view(), name="active_user"), path('forget/', ForgetPwdView.as_view(), name="forget_pwd"), re_path('reset/(?P<active_code>.*)/', ResetPasswordView.as_view(), name="reset_password"), # 下面的页面就是重载的教育机构信息页面 部分继承的展示操作 path('org/', include('apps.organization.urls', namespace="org")), # 个人中心页面的配置 # path('center/',UserCenterView.as_view(),name='user_center'), # 课程详情页面 path('course/', include('apps.courses.urls', namespace="course")), path('users/', include('apps.users.urls', namespace="users")), # 加载上传图片的问题 re_path('media/(?P<path>.*)', serve, {"document_root": MEDIA_ROOT}),
from apps.users.views import LoginView, RegisterView, ActiveUserView, ForgetPwdView, ResetView, ModifyPwdView from apps.organization.views import OrgView from django.views.static import serve from MxOnline.settings import MEDIA_ROOT from MxOnline.settings import STATIC_ROOT urlpatterns = [ path('xadmin/', xadmin.site.urls), path('', TemplateView.as_view(template_name='index.html'), name='index'), path('login/', LoginView.as_view(), name='login'), path('register/', RegisterView.as_view(), name='register'), path('captcha/', include('captcha.urls')), re_path('active/(?P<active_code>.*)/', ActiveUserView.as_view(), name='user_active'), path('forget/', ForgetPwdView.as_view(), name='forget_pwd'), re_path('reset/(?P<active_code>.*)/', ResetView.as_view(), name='reset_pwd'), path('modify_pwd/', ModifyPwdView.as_view(), name='modify_pwd'), path("org/", include('organization.urls', namespace="org")), # 处理图片显示的url,使用Django自带serve,传入参数告诉它去哪个路径找,我们有配置好的路径MEDIAROOT re_path(r'^media/(?P<path>.*)', serve, {"document_root": MEDIA_ROOT}), path("course/", include('course.urls', namespace="course")), re_path('course/(?P<course_id>\d+)/', CourseDetailView.as_view(), name="course_detail"), # 课程章节信息页 re_path('info/(?P<course_id>\d+)/', CourseInfoView.as_view(),
3. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls)) """ from django.conf.urls import url, include from django.views.generic import TemplateView from django.views.static import serve import xadmin from apps.users.views import LoginView, RegisterView, ActiveUserView, \ ForgetPwdView, ResetView, ModifyPwdView from apps.organization.views import OrgView from settings import MEDIA_ROOT urlpatterns = [ url(r'^xadmin/', xadmin.site.urls), url('^$', TemplateView.as_view(template_name="index.html"), name="index"), url('^login/$', LoginView.as_view(), name="login"), url('^register/$', RegisterView.as_view(), name="register"), url(r'^captcha/', include('captcha.urls')), url(r'^active/(?P<active_code>.*)/$', ActiveUserView.as_view(), name="user_active"), url(r'^reset/(?P<active_code>.*)/$', ResetView.as_view(), name="reset_pwd"), url(r'^forget/$', ForgetPwdView.as_view(), name="forget_pwd"), url(r'^modifypwd/$', ModifyPwdView.as_view(), name="modify_pwd"), # 课程机构首页 url(r'^org_list/$', OrgView.as_view(), name="org_list"), # 处理静态文件,上传文件的访问处理 url(r'^media/(?P<path>.*)$', serve, {"document_root": MEDIA_ROOT}) ]