Including another URLconf 1. Add an import: from blog import urls as blog_urls 2. Import the include() function: from django.conf.urls import url, include 3. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls)) """ from django.conf.urls import url, include import xadmin from django.views.static import serve from users.views import LoginView, RegisterView, ActiveUserView, ForgetPwdView, ResetView, ModifyPwdView, LogoutView from users.views import IndexView from organization.views import OrgView from MxOnline.settings import MEDIA_ROOT urlpatterns = [ url(r'^xadmin/', xadmin.site.urls), url('^$', IndexView.as_view(), name="index"), #process static file url('^login/$', LoginView.as_view(), name="login"), url('^logout/$', LogoutView.as_view(), name="logout"), 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'^forget/$', ForgetPwdView.as_view(), name="forget_pwd"), url(r'^reset/(?P<active_code>.*)/$', ResetView.as_view(), name="reset_pwd"), url(r'^modify_pwd/$', ModifyPwdView.as_view(), name="modify_pwd"), #organization url setting url(r'^org/', include('organization.urls', namespace="org")), #the process function that configure the upload file's access url(r'^media/(?P<path>.*)', serve, {"document_root": MEDIA_ROOT}),
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin from django.urls import path, include, re_path from django.views.generic import TemplateView from django.views.static import serve import xadmin from users.views import LoginView, RegisterView, ActiveUserView, ForgetPwdView, ResetView, ModifyPwdView, LogoutView, IndexView from muke.settings import MEDIA_ROOT, STATIC_ROOT urlpatterns = [ path('xadmin/', xadmin.site.urls), path('', IndexView.as_view(), name='index'), path('login/', LoginView.as_view(), name='login'), path('logout/', LogoutView.as_view(), name='logout'), path('register/', RegisterView.as_view(), name='register'), path('captcha/', include('captcha.urls')), re_path('active/(?P<active_code>\w+.*)/', ActiveUserView.as_view(), name="user_active"), path('forget/', ForgetPwdView.as_view(), name='forget_pwd'), re_path('reset/(?P<active_code>\w+.*)/', ResetView.as_view(), name="reset_pwd"), path('modify_pwd/', ModifyPwdView.as_view(), name='modify_pwd'), # 课程机构url配置 path('org/', include('organization.urls', namespace='org')), # 课程url配置 path('course/', include('courses.urls', namespace='course')),
Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') Class-based views 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.views.static import serve # from django.contrib import admin from YDX.settings import MEDIA_ROOT from users.views import IndexView from otherapps import xadmin from users.views import LoginView urlpatterns = [ url(r'^admin/', xadmin.site.urls), url(r'^login/', LoginView.as_view(), name='login'), url(r'index/', IndexView.as_view(), name="index"), url("users/", include('users.urls', namespace="users")), url("courses/", include('courses.urls', namespace="courses")), url("teachers/", include('teachers.urls', namespace="teachers")), url(r'^captcha/', include('captcha.urls')), url('media/(?P<path>.*)', serve, {"document_root": MEDIA_ROOT}), url('fights/', include('trade.urls', namespace='fights')) ] handler404 = 'users.views.page_not_found' handler500 = 'users.views.page_error'
Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: path('', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.conf import settings from django.urls import path, include, re_path from django.views.static import serve from extra_apps import xadmin from users.views import IndexView import users.views as view urlpatterns = [ path('admin/', xadmin.site.urls), path('captcha/', include('captcha.urls')), path('ueditor/', include('DjangoUeditor.urls')), path('users/', include(('users.urls', 'users'), namespace='users')), path('course/', include(('courses.urls', 'courses'), namespace='courses')), path('orgs/', include(('orgs.urls', 'orgs'), namespace='orgs')), path('operations/', include(('operations.urls', 'operations'), namespace='operations')), path('', IndexView.as_view()), re_path(r'^media/(?P<path>.*)', serve, {"document_root": settings.MEDIA_ROOT}), ] # handler404 = 'users.views.page_not_found_error' handler500 = 'users.views.page_error'
2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ import xadmin from django.contrib import admin from django.urls import path, re_path, include from django.views.generic import TemplateView from django.views.static import serve from MxOnline.settings import MEDIA_ROOT from users.views import LoginView, LogoutView, RegisterView from users.views import IndexView, ActiveUserView, ForgetPwdView, ResetView, ModifyPwdView urlpatterns = [ # path('admin/', admin.site.urls), path('xadmin/', xadmin.site.urls), re_path(r'^$', IndexView.as_view(), name='index'), re_path(r'^login/$', LoginView.as_view(), name='login'), re_path(r'^logout/$', LogoutView.as_view(), name='logout'), path('register/', RegisterView.as_view(), name='register'), path('captcha/', include('captcha.urls')), re_path(r'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'), # 处理图片显示的url,使用Django自带serve,传入参数告诉它去哪个路径找,我们有配置好的路径MEDIAROOT re_path(r'^media/(?P<path>.*)', serve, {"document_root": MEDIA_ROOT}),
from django.conf.urls import url, include from django.views.generic import TemplateView from django.views.static import serve from django.conf.urls import handler404, handler500 import xadmin from users.views import LoginView, RegisterView, ActiveUserView, ForgetPwdView, ResetView, ModifyPwdView, LogoutView, \ IndexView from .settings import MEDIA_ROOT # from .settings import STATIC_ROOT urlpatterns = [ url(r'^xadmin/', xadmin.site.urls), url('^$', IndexView.as_view(), name="index"), url('^teacher/$', IndexView.as_view(), name="teacher_index"), url('^login/$', LoginView.as_view(), name="login"), url('^logout/$', LogoutView.as_view(), name="logout"), 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'^forget/$', ForgetPwdView.as_view(), name="forget_pwd"), url(r'^reset/(?P<active_code>.*)/$', ResetView.as_view(), name="reset_pwd"), url(r'^modify_pwd/$', ModifyPwdView.as_view(), name="modify_pwd"), url(r'^team/', include(('teams.urls', 'teams'), namespace='teams')), url(r'^media/(?P<path>.*)$', serve, {"document_root": MEDIA_ROOT}), # url(r'^static/(?P<path>.*)$', serve, {"document_root":STATIC_ROOT}),
from django.contrib import admin import xadmin from users.views import LoginView,RegisterView,ActiveUserView,ForgetPwdView,ResetUserView,ModifyPwdView,LogOutView,IndexView from django.views.generic import TemplateView from django.views.static import serve import captcha from .settings import MEDIA_ROOT from organiation import urls as org_urls from courses import urls as course_urls from users import urls as user_urls urlpatterns = [ url(r'^xadmin/', xadmin.site.urls), url(r'^login/$',LoginView.as_view() ,name='login'), url(r'^logout/$',LogOutView.as_view() ,name='logout'), url(r'^register/$',RegisterView.as_view() ,name='register'), url(r"^$",IndexView.as_view(),name='index'), url(r'^captcha/',include('captcha.urls')), url(r'^active/(?P<active_code>.*$)',ActiveUserView.as_view(),name='active'), url(r'^reset/(?P<reset_code>.*$)',ResetUserView.as_view(),name='reset'), url(r'^modify_pwd/$',ModifyPwdView.as_view(),name='modify_pwd'), url(r'^forget/$',ForgetPwdView.as_view(),name="forget"), #课程机构url # url(r'^org_list/$',OrgView.as_view(),name='org_list'), url(r'^org/',include(org_urls,namespace='org')), #上传文件的访问处理函数 url(r'^media/(?P<path>.*)$',serve,{'document_root':MEDIA_ROOT}), # 生产模式服务器静态文件url # url(r'^static/(?P<path>.*)$',serve,{'document_root':STATIC_ROOT}), # 课程相关url url(r'^course/',include(course_urls,namespace='course')), # 教师相关url
#找回密码的邮件发送 re_path("forgetpwd/", ForgetPwdView.as_view(), name="forgetpwd"), re_path("reset/(?P<reset>.*)/$", ResetView.as_view()), #机构模块 #首页 path("org/", include("organization.urls")), #课程模块 #首页 path("course/", include("courses.urls")), #用户模块 #个人中心 path("users/", include("users.urls")), #主页,在根路径下就可以显示这个页面 path("index/", IndexView.as_view(), name="index"), re_path("^$", IndexView.as_view(), name="index"), #退出 path("logout/", logout, name="logout"), #验证码图片 re_path("^captcha/", include("captcha.urls")), #富文本url path('ueditor/', include('DjangoUeditor.urls')), #当debug=false时,STATICFILES_DIRS将失效,必须从新配置 # re_path('^static/(?P<path>.*)$', static.serve, {'document_root': MEDIA_ROOT}, name='static') re_path(r'^static/(?P<path>.*)$', static.serve, {"document_root": MEDIA_ROOT}), ] #整个项目全局404配置 handler404 = "users.views.page_not_found" handler500 = "users.views.server_error"
from django.urls import path from django.contrib import admin from django.urls import include from django.conf.urls import url from django.contrib import admin from django.urls import path from users.views import LoginView, LogoutView, RegisterView, ActiveUserView, ForgetPwdView, ResetView, ModifyPwdView, IndexView from django.views.generic import TemplateView urlpatterns = [ path('admin/', admin.site.urls), url('^$', TemplateView.as_view(template_name='index.html'), name='index'), url('^login/$', LoginView.as_view(), name='login'), url('^logout/$', LogoutView.as_view(), name='logout'), url('^index/$', IndexView.as_view(), name='home'), url('^register/$', RegisterView.as_view(), name='register'), url('captcha/', include('captcha.urls')), url(r'^active/(?P<active_code>.*)/$', ActiveUserView.as_view(), name="user_active"), # 忘记密码 url('^forget/$', ForgetPwdView.as_view(), name='forget_pwd'), # 重置密码时发送的邮箱链接 url(r'^reset/(?P<active_code>.*)/$', ResetView.as_view(), name="reset_pwd"), # 重置密码 url('^modify_pwd/$', ModifyPwdView.as_view(), name='modify_pwd'), ]
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. Add an import: from blog import urls as blog_urls 2. Import the include() function: from django.conf.urls import url, include 3. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls)) """ from django.conf.urls import include, url from django.contrib import admin from users.views import IndexView from django.conf import settings from django.contrib.auth import views as auth_views from django.views.static import serve from django.conf.urls.static import static urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^', include('myshopping.urls')), url(r'^', include('users.urls')), url(r'^$', IndexView.as_view(), name="user-home"), # url(r'', include('django_braintree.urls')), ] if settings.DEBUG: urlpatterns += [ url(r'^media/(.*)$', serve, {'document_root': settings.MEDIA_ROOT}), ]
from django.views.static import serve import users import xadmin from django.views.generic import TemplateView # from users.views import user_login from Mxonline3.settings import MEDIA_ROOT from organization.views import OrgView from users.views import LoginView, RegisterView, ActiveUserView, ForgetPwdView, ResetView, ModifyPwdView, LogoutView, \ IndexView urlpatterns = [ path('xadmin/', xadmin.site.urls), # TemplateView.as_view会将template转换为view #path('', TemplateView.as_view(template_name= "index.html"), name= "index"), path('', IndexView.as_view(), name= "index"), # 基于类方法实现登录,这里是调用它的方法 path('login/', LoginView.as_view(), name="login"), # 退出功能url path('logout/', LogoutView.as_view(), name="logout"), # 注册url path("register/", RegisterView.as_view(), name = "register" ), # 验证码url path("captcha/", include('captcha.urls')), # 激活用户url re_path('active/(?P<active_code>.*)/', ActiveUserView.as_view(), name= "user_active"), # 忘记密码
from django.contrib import admin from django.conf.urls import url, include import xadmin from django.views.generic import TemplateView from users.views import LoginView, RegisterView, ActiveUserView, ForgetPwdView, ResetView, ModifyPwdView, LogoutView from organization.views import OrgView from django.views.static import serve from djtest.settings import MEDIA_ROOT from users.views import IndexView, page_error, page_not_found handler404 = page_not_found handler500 = page_error urlpatterns = [ # path('admin/', admin.site.urls), url(r'^xadmin/', xadmin.site.urls), url('^$', IndexView.as_view(), name='index'), # url('^login/$', user_login, name='login'), # 指向函数,而不是调用,所以没有括号 url('^login/$', LoginView.as_view(), name='login'), # 这里是方法,有括号 url('^logout/$', LogoutView.as_view(), name='logout'), # 这里是方法,有括号 url('^index/$', IndexView.as_view(), name='index'), url('^register/$', RegisterView.as_view(), name='register'), url('^captcha/', include('captcha.urls')), url(r'^active/(?P<active_code>.*)/$', ActiveUserView.as_view(), name='user_active'), # ?P(p是大写的)提取一个变量作为参数 <active_code>是变量名,再后面是正则表达式 url('^forget/$', ForgetPwdView.as_view(), name='forget_pwd'), url(r'^reset/(?P<active_code>.*)/$', ResetView.as_view(), name='reset_pwd'), url(r'^modify_pwd/$', ModifyPwdView.as_view(), name='modify_pwd'), # 配置上传文件的访问处理函数
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. Add an import: from blog import urls as blog_urls 2. Import the include() function: from django.conf.urls import url, include 3. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls)) """ from django.conf.urls import url, include from django.contrib import admin import xadmin from users.views import IndexView, LoginView, RegisterView, CommentView, AddCommentView, tableView, LogoutView, UserShowView, UserModifyView, UserAuthShowView, GrantUserAuthView urlpatterns = [ url(r'^xadmin/', xadmin.site.urls), url(r'^$', IndexView.as_view(), name="index"), url(r'^search/$', IndexView.as_view(), name="search"), url(r'^login/', LoginView.as_view(), name="login"), url(r'^register/', RegisterView.as_view(), name="register"), url(r'^logout/', LogoutView.as_view(), name="logout"), url(r'^UserShow/', UserShowView.as_view(), name="UserShow"), url(r'^UserModify', UserModifyView.as_view(), name="UserModify"), url(r'^Comment/', CommentView.as_view(), name="Comment"), url(r'^addComment', AddCommentView.as_view(), name="addComment"), url(r'^table/', tableView.as_view(), name="table"), url(r'^user_auth', UserAuthShowView.as_view(), name="user_auth"), url(r'^grant_user_auth', GrantUserAuthView.as_view(), name="grant_user_auth"), url(r'^supplied/', include('supplied.urls', namespace="supplied")), ]
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') Including another URLconf 1. Add an import: from blog import urls as blog_urls 2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls)) """ from django.conf.urls import include, url from django.contrib import admin from django.views.generic import TemplateView from django.views.static import serve from pointshop.settings import MEDIA_ROOT from users.views import HomeView, ShopCartView, IndexView, TesttView from products.views import CategoryListView, CategoryView, ProductionView urlpatterns = [ url(r'^admin/', include(admin.site.urls)), url(r'^index/$', IndexView.as_view(), name="index"), url(r'^$', IndexView.as_view(), name="index"), url(r'^media/(?P<path>.*)$', serve, {"document_root": MEDIA_ROOT}), url(r'^home/$', HomeView.as_view(), name="home"), url(r'^category/list/(?P<id>\d+)$', CategoryListView.as_view(), name="category_list"), url(r'^category/$', CategoryView.as_view(), name="category"), url(r'^shopcart/$', ShopCartView.as_view(), name="shopcart"), url(r'^production/(?P<p_id>\d+)$', ProductionView.as_view(), name="productions"), url(r'ckeditor/', include('ckeditor_uploader.urls')), url(r'^test/$', TesttView.as_view(), name="test") ]
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') Class-based views 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.urls import path, re_path, include from django.contrib import admin from django.conf import settings from django.views.static import serve from users.views import IndexView,LoginView,LoginOutView,RegisterView,UserInfoView,PwdView from movies.views import AnimationView,PlayView,SearchView from django.conf.urls.static import static urlpatterns = [ path('admin/', admin.site.urls), re_path('(?P<page>\d+)/$',IndexView.as_view(),name="index"), path('login/',LoginView.as_view(),name="login"), path('logout/',LoginOutView.as_view(),name="logout"), path('register/',RegisterView.as_view(),name="register"), path('animation/',AnimationView.as_view(),name="animation"), re_path('play/(?P<id>\d+)/$',PlayView.as_view(),name="play"), # re_path(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}), path('userinfo/',UserInfoView.as_view(),name='userinfo'), path('changepwd/',PwdView.as_view(),name='changepwd'), path('search/',SearchView.as_view(),name='search'), ] urlpatterns += static('/media/', document_root=settings.MEDIA_ROOT)
router.register(r'gears', GearViewSet) router.register(r'gearproperties', GearPropertyViewSet) router.register(r'gearavailabilities', GearAvailabilityViewSet) router.register(r'gearimages', GearImageViewSet) router.register(r'locations', LocationViewSet) router.register(r'transactions', TransactionViewSet) urlpatterns = [ url(r'^admin/', include(admin.site.urls)), url(r'^loginwidget/', LoginWidgetView.as_view(), name='loginwidget'), url(r'^logout/', LogoutView.as_view(), name='logout'), url(r'^home/', login_required(HomeView.as_view()), name='home'), url(r'^myaccount/', login_required(MyAccountView.as_view()), name='myaccount'), #url(r'^users/(?P<user_id>\w+)/$', UserView.as_view(), name='user'), url(r'^gear/(?P<gear_id>\w+)/$', login_required(GearView.as_view()), name='gear'), url(r'^addgear/', login_required(AddGearView.as_view()), name='addgear'), url(r'^api/v1/', include(router.urls)), url(r'^demo/', IndexView.as_view(), name='index'), url(r'^get-sms-code/', csrf_exempt(CreateCodeView.as_view()), name='create_code'), url(r'^validate-sms-code/', csrf_exempt(ValidateCodeView.as_view()), name='validate_code'), url(r'^$', TempIndexView.as_view(), name='temp_index'), ]
2. Import the include() function: from django.conf.urls import url, include 3. 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 # 专门用于处理静态文件 import xadmin from django.views.static import serve # 用于处理静态文件 from users.views import LogoutView, LoginView, RegisterView, ActiveUserView, ForgetPwdView, ResetView, ModifyPwdView from users.views import IndexView from Lfonlion.settings import MEDIA_ROOT urlpatterns = [ url(r'^xadmin/', xadmin.site.urls), # 后台管理url url('^$', IndexView.as_view(), name="index"), # TemplateView.as_view(template_name="index.html") url('^login/$', LoginView.as_view(), name="login"), # 登录url # url('^login/$', LoginUnsafeView.as_view(), name="login"), # sql注入验证 url('^logout/$', LogoutView.as_view(), name="logout"), # 退出登录url url('^register/$', RegisterView.as_view(), name="register"), # 注册url url(r'^captcha/', include('captcha.urls')), # 生成验证码 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/$', ModifyPwdView.as_view(), name="modify_pwd"), # 课程机构url设置 url(r'^org/', include('organization.urls', namespace="org")), # 课程相关url设置 url(r'^course/', include('courses.urls', namespace="course")),
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 import xadmin from django.views.generic import TemplateView from users.views import LoginView, RegisterView, ForgetPwdView, LogOutView from users.views import ActiveUserView, ResetView, ModifyPwdView, IndexView from django.views.static import serve from online_education.settings import MEDIA_ROOT #, #STATIC_ROOT urlpatterns = [ url(r'^xadmin/', xadmin.site.urls), url('^$', IndexView.as_view(), name="index"), # TemplateView.as_view(template_name="index.html") url(r'^login/$', LoginView.as_view(), name="login"), url(r'^logout/$', LogOutView.as_view(), name="logout"), url(r'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'^forget/$', ForgetPwdView.as_view(), name="forget_pwd"), url(r'^reset/(?P<active_code>.*)/$', ResetView.as_view(), name="reset_pwd"), url(r'^modify_pwd/$', ModifyPwdView.as_view(), name="modify_pwd"), # 课程机构url url(r'^org/', include('organization.urls'), name="org"),
""" # from django.contrib import admin from django.urls import path, include, re_path import xadmin from sundjango.settings import MEDIA_ROOT from django.views.static import serve from django.views.generic import TemplateView from users.views import LoginView, RegisterView, ActiveUserView, ForgetPwdView, ResetView, ModifyPwdView, LogoutView, IndexView from organization.views import OrgView # 函数方法 # from users import views urlpatterns = [ path('xadmin/', xadmin.site.urls), path('', IndexView.as_view(), name='index'), # 用户 path('login/', LoginView.as_view(), name='login'), path('logout/', LogoutView.as_view(), name='logout'), path('register/', RegisterView.as_view(), name='register'), # path('login/', views.user_login, name='login'), 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(r'reset/(?P<active_code>.*)/', ResetView.as_view(), name='reset_pwd'), path('modify_pwd/', ModifyPwdView.as_view(), name='modify_pwd'), # 个人信息 path("users/", include('users.urls', namespace="users")),
from django.conf.urls import url, include # from django.contrib import admin # from django.views.generic import TemplateView # 处理静态文件 import xadmin from users.views import IndexView from django.views.static import serve # from users.views import log_in from users.views import LoginView, RegisterView, ActiveUserView, ForgetPwdView, ResetView, ModifyPwdView, LogoutView from organization.views import OrgView from Mxonlie.settings import MEDIA_ROOT urlpatterns = [ url(r'^xadmin/', xadmin.site.urls), # url(r'^$', TemplateView.as_view(template_name='index.html'), name="index"), # 这样不用写views url(r'^$', IndexView.as_view(), name="index"), # 这样不用写views url(r'^login/$', LoginView.as_view(), name="login"), # 基于类的方式,别忘记as_view()后面的括号 url(r'^logout/$', LogoutView.as_view(), name="logout"), url(r'^register/$', RegisterView.as_view(), name="register"), # 基于类的方式,别忘记as_view()后面的括号 url(r'^captcha/', include('captcha.urls')), # 验证码 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/$', ModifyPwdView.as_view(), name="modify_pwd"),
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.views.static import serve import xadmin from users.views import LoginView, LogoutView, RegisterView, ActiveUserView, ForgetPwdView, ResetView, ModifyPwdView from users.views import IndexView from testonline.settings import MEDIA_ROOT urlpatterns = [ url(r'^xadmin/', xadmin.site.urls), url('^$', IndexView.as_view(), name="index"), url('^login/$', LoginView.as_view(), name="login"), url('^logout/$', LogoutView.as_view(), name="logout"), 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'^forget/$', ForgetPwdView.as_view(), name="forget_pwd"), url(r'^reset/(?P<active_code>.*)/$', ResetView.as_view(), name="reset_pwd"), url(r'^modify_pwd/$', ModifyPwdView.as_view(), name="modify_pwd"), # 课程机构url配置 url(r'^org/', include('organization.urls', namespace='org')), # 课程相关url配置 url(r'^course/', include('courses.urls', namespace='course')),
Including another URLconf 1. Add an import: from blog import urls as blog_urls 2. Import the include() function: from django.conf.urls import url, include 3. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls)) """ from django.conf.urls import url, include from users.views import IndexView import xadmin #导入xadmin from django.views.generic import TemplateView #采用视图模板 from django.views.static import serve from Mxonline.settings import MEDIA_ROOT, STATIC_ROOT urlpatterns = [ url(r'^xadmin/', xadmin.site.urls), #将默认admin改为xadmin url(r'^$', IndexView.as_view(), name="index"), #采用视图模板,其他应用的views采用类视图 url(r'^users/', include('users.urls', namespace='users', app_name='users')), url( r'^organization/', include('organization.urls', namespace='organization', app_name='organization')), url(r'^courses/', include('courses.urls', namespace='courses', app_name='courses')), url(r'^captcha/', include('captcha.urls')), #注册模块验证码,要进行数据迁移生成验证码的表 url(r'^media/(?P<path>.*)$', serve, {"document_root": MEDIA_ROOT}), url(r'^ueditor/', include('DjangoUeditor.urls')), # 处理图片显示的url,使用Django自带serve,传入参数告诉它去哪个路径找,我们有配置好的路径MEDIAROOT #url(r'^static/(?P<path>.*)$', serve, {"document_root":STATIC_ROOT}), ]
1. Add an import: from blog import urls as blog_urls 2. Import the include() function: from django.conf.urls import url, include 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 from extra_apps import xadmin from users.views import LoginView, RegisterView, ActiveUserView, ForgetPwdView, ResetView, ModifyPwdView from users.views import LogoutView, IndexView from Gmooc.settings import MEDIA_ROOT, STATIC_ROOT urlpatterns = [ url(r'^xadmin/', xadmin.site.urls), url('^$', IndexView.as_view(), name='index'), # 对应在html文件中的url url('^login/$', LoginView.as_view(), name='login'), # 对应在html文件中的url url('^logout/$', LogoutView.as_view(), name='logout'), # 对应在html文件中的url url('^register/$', RegisterView.as_view(), name='register'), # 对应在html文件中的url url(r'^captcha/', include('captcha.urls')), 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<reset_code>.*)/$', ResetView.as_view(), name='reset_pwd'), url(r'^modify_pwd/$', ModifyPwdView.as_view(), name='modify_pwd'), # 课程机构url配置 url(r'^org/', include('organization.urls', namespace='org')), # 课程相关url配置
from django.conf.urls import include, url,patterns from django.contrib import admin from users.views import RegisterView, IndexView,LoginView,UserView,LogoutView from django.views.generic import View urlpatterns = patterns('', # Examples: # url(r'^$', 'project.views.home', name='home'), # url(r'^blog/', include('blog.urls')), url(r'^$',IndexView.as_view()), url(r'^register$', RegisterView.as_view()), url(r'^login$', LoginView.as_view()), url(r'^logout$',LogoutView.as_view()), url(r'^(?P<username>[\w\-]+)$', UserView.as_view()), )
Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: path('', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.conf.urls.static import static from django.contrib import admin from django.contrib.auth.decorators import login_required from django.urls import path, include from sqlaudit import settings from users.views import IndexView urlpatterns = [ path('admin/', admin.site.urls), path(r'', login_required(IndexView.as_view()), name="p_index"), path('users/', include('users.urls')), path('sqlorders/', include('sqlorders.urls')), path('sqlquery/', include('sqlquery.urls')), path('webshell/', include('webshell.urls')), path('settings/', include('externd.urls')), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
from users.views import RegisterView, LoginView, PreferencesView, activate, IndexView, SendEmailVerification urlpatterns = [ path('admin/', admin.site.urls), path('verify_email/', SendEmailVerification.as_view(), name='send-email-verification'), path('auth/', include('django.contrib.auth.urls')), path('login/', LoginView.as_view(), name='login'), # path('logout/', LogoutView.as_view(), name="logout"), path('register/', RegisterView.as_view(), name='register'), path('preferences/', PreferencesView.as_view(), name='preferences'), # path('preferences/update', PreferencesView.as_view(), name='update-profile'), path('', IndexView.as_view(), name='home'), # path('activate/<uidb64>/<token>', activate, name="activate"), re_path( r'^activate/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', activate, name='activate'), ] from django.conf import settings from django.urls import include, path # For django versions from 2.0 and up if settings.DEBUG: import debug_toolbar urlpatterns = [ path('__debug__/', include(debug_toolbar.urls)),
2. Import the include() function: from django.conf.urls import url, include 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 users.views import LogoutView, LoginView, RegisterView, ActiveUserView, IndexView, ForgetPwdView, ResetView, ModifyPwdView from JBBSystem.settings import MEDIA_ROOT urlpatterns = [ url(r'^xadmin/', xadmin.site.urls), url(r'^$', IndexView.as_view(), name="index"), # 直接显示index.html页面 # url('^login/$', user_login, name="login") # 访问login句柄(注意不是调用函数,而是指向函数) url(r'^login/$', LoginView.as_view(), name="login"), # 此处调用的是函数方法 url(r'^logout/$', LogoutView.as_view(), name="logout"), # 此处调用的是函数方法 url(r'^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'^forget/$', ForgetPwdView.as_view(), name="forget_pwd"), url(r'^reset/(?P<active_code>.*)/$', ResetView.as_view(), name="reset_pwd"), url(r'^modify_pwd/$', ModifyPwdView.as_view(), name="modify_pwd"), # 课程机构url配置 url(r'^org/', include('organization.urls', namespace="org")),
from django.contrib import admin from django.views.generic import TemplateView import xadmin from django.views.static import serve from users.views import LoginView, RegisterView, ActiveUserView, ForgetPwdView, ResetView, ModifyPwdView, LogoutView from users.views import IndexView from organization.views import OrgView from mxonline.settings import MEDIA_ROOT, MEDIA_URL #,STATIC_ROOT from django.conf.urls.static import static urlpatterns = [ url(r'^xadmin/', xadmin.site.urls), url('^$', IndexView.as_view(), name="index"), url('^login/$', LoginView.as_view(), name="login"), url('^logout/$', LogoutView.as_view(), name="logout"), 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'^forget/$', ForgetPwdView.as_view(), name="forget"), url(r'^reset/(?P<active_code>.*)/$', ResetView.as_view(), name="reset_pwd"), url(r'^modify_pwd/$', ModifyPwdView.as_view(), name="modify_pwd"), #配置上传文件的访问处理函数 url(r'^media/(?P<path>.*)$', serve, {"document_root": MEDIA_ROOT}), # url(r'^static/(?P<path>.*)$', serve, {"document_root":STATIC_ROOT}),
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.conf.urls import patterns from django.contrib.auth.decorators import login_required from users.views import UserFormView, IndexView from tastypie.api import Api from users.api import UserResource v1_api = Api(api_name='v1') v1_api.register(UserResource()) urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^api/', include(v1_api.urls)), url(r'^user-form/$', login_required(UserFormView.as_view()), name='user_form'), url(r'^$', IndexView.as_view(), name='index_user'), ]
from django.contrib import admin from django.views.static import serve # from apps.users import views as users_views import xadmin from guqiwebsite.settings import MEDIA_ROOT from users.views import IndexView from products import views as product_views urlpatterns = [ # 管理界面的url url(r'^admin/', xadmin.site.urls), # 首页的URL url(r'^$', IndexView.as_view(), name='index'), # 配置上传文件的访问处理函数 url(r'^media/(?P<path>.*)/$', serve, {'document_root': MEDIA_ROOT}), # 内容类的URL url( r'^blog/', include('blog.urls', namespace='blog'), ), # 用户界面的url url( r'^users/', include('users.urls', namespace='users'), ),
from django.urls import path from users.views import IndexView, CreateView, UpdateView, DetailView, DeleteView from django.contrib.auth.decorators import login_required app_name = 'users' urlpatterns = [ path('', login_required(IndexView.as_view()), name='index'), path('create', login_required(CreateView.as_view()), name='create'), path('<int:pk>/edit', login_required(UpdateView.as_view()), name='edit'), path('<int:pk>', login_required(DetailView.as_view()), name='show'), path('<int:pk>/delete', login_required(DeleteView.as_view()), name='delete'), ]
# from myechart import EchartView01 # from blog.views import IndexView, ArticleDetailView,CategoryView,TagView from .widgets import NewClientsWidget router.register(NewClientsWidget, 'new_users_widget') urlpatterns = [ path('xadmin/', xadmin.site.urls), # TemplateView.as_view会将template转换为view #path('', TemplateView.as_view(template_name= "index.html"), name= "index"), path('blank/', TemplateView.as_view(template_name= "blank.html"), name= "blank"), path('', IndexView.as_view(), name= "index"), # 基于类方法实现登录,这里是调用它的方法 path('login/', LoginView.as_view(), name="login"), # 退出功能url path('logout/', LogoutView.as_view(), name="logout"), # 注册url path("register/", RegisterView.as_view(), name = "register" ), # 验证码url path("captcha/", include('captcha.urls')), # 激活用户url re_path('active/(?P<active_code>.*)/', ActiveUserView.as_view(), name= "user_active"),
from users.views import SendTrainerMessageView from users.views import IndexView from users.views import TrainerLoginView from users.views import TrainerDashboardView from users.views import SendClientMessageView from users.views import GetUserChatView urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^trainers/login/$', TrainerLoginView.as_view(), name='trainer-login-view'), url(r'^trainers/dashboard/$', TrainerDashboardView.as_view(), name='trainer-dashboard-view'), url(r'^trainers/send-client-message/$', SendClientMessageView.as_view(), name="send-client-message"), url(r'^trainers/get-user-chat/$', GetUserChatView.as_view(), name='get-user-chat-view'), urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^users/login/$', LoginView.as_view(), name='login-view'), url(r'^users/logout/$', LogoutView.as_view(), name='logout-view'), url(r'^users/registration/$', RegistrationView.as_view(), name='registration-view'), url(r'^dashboard/$', DashboardView.as_view(), name="dashboard-view"), url(r'^dashboard/send-trainer-message/$', SendTrainerMessageView.as_view(), name="send-trainer-message"), url(r'^$', IndexView.as_view(), name='index') url(r'^$', RedirectView.as_view(url='users/login/')) ]