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 from django.contrib import admin from blogs.views import index, SearchView, blog_list, blog_detail, CommentView from users.views import LoginView, RegisterView, ActiveView, LogoutView urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^$', index, name='index'), url(r'^list$', blog_list, name='blog_list'), url(r'^search$', SearchView.as_view(), name='search'), url(r'^category/(?P<cid>[0-9]+)/$', blog_list), url(r'^tags/(?P<tid>[0-9]+)/$', blog_list), url(r'^blog/(?P<bid>[0-9]+)/$', blog_detail, name='blog_detail'), url(r'^comment/(?P<bid>[0-9]+)$', CommentView.as_view(), name='comment'), url(r'^login/', LoginView.as_view(), name='login'), url(r'^register/', RegisterView.as_view(), name='register'), url(r'^active/(?P<active_code>[a-zA-Z0-9]+)', ActiveView.as_view(), name='active'), url(r'^logout/', LogoutView.as_view(), name='logout'), ]
from django.conf.urls import url, include import xadmin from django.views.static import serve from users.views import LoginView, RegisterView, ActiveView, \ ForgetPwdView, ResetPwdView, ModifyPwdView, LogoutView, IndexView from learn_online.settings import MEDIA_ROOT #, STATIC_ROOT urlpatterns = [ url(r'^xadmin/', include(xadmin.site.urls)), url(r'^$', IndexView.as_view(), name='index'), 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>.*)/$', ActiveView.as_view(), name='active'), url(r'^forget/$', ForgetPwdView.as_view(), name='forget_pwd'), url(r'^reset/(?P<reset_code>.*)/$', ResetPwdView.as_view(), name='reset_pwd'), url(r'^modify/$', 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}), # 课程机构URL配置 url(r'^org/', include('organization.urls', namespace='org')), # 课程相关URL配置 url(r'^course/', include('courses.urls', namespace='course')), # 用户相关url配置 url(r'users/', include('users.urls', namespace='users')), ]
# from binshop.settings import STATIC_ROOT,MEDIA_ROOT urlpatterns = [ path('admin/doc/', include('django.contrib.admindocs.urls')), path('admin/', admin.site.urls), path('xadmin/', xadmin.site.urls), path('', IndexView.as_view(), name='index'), path('users/', include('users.urls')), # path('login/', login_1, name='login'), path('login/', LoginView.as_view(), name='login'), path('register/', RegisterView.as_view(), name='register'), path('logout/', LogoutView.as_view(), name='logout'), re_path('active/(?P<active_code>.*)/', ActiveView.as_view(), name='active'), # path('active/<str:code>', RegisterView.as_view(), name='register'), path('forget/', ForgetView.as_view(), name='forget_pwd'), path('reset/', ResetView.as_view(), name='reset_pwd'), path('captcha/', include('captcha.urls')), path('goods/', include('goods.urls')), path('goods/<int:id>/', GoodDetailView.as_view(), name='good_detail'), path('category/<int:id>/', CategoryView.as_view(), name='category'), path('cart/', ShoppingCartView.as_view(), name='cart'), path('order/', include('trade.urls')), path('alipay/return/', AlipayView.as_view(), name='alipay'),
import xadmin from users.views import LoginView, RegisterView, ActiveView, ForgetPwdView, ResetView, ModifyPwdView, LogoutView from users.views import IndexView from MxOnline.settings import MEDIA_ROOT urlpatterns = [ url(r'^xadmin/', xadmin.site.urls), url(r'^captcha/', include('captcha.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('^active/(?P<active_code>\w+)/$', ActiveView.as_view(), name='active'), url('^forget/$', ForgetPwdView.as_view(), name='forget'), url('^reset/(?P<reset_code>\w+)/$', ResetView.as_view(), name='reset'), url('^modify_pwd/$', ModifyPwdView.as_view(), name='modify'), # 课程机构URL配置 url(r'^org/', include('organization.urls', namespace='org')), # 课程相关URL配置 url(r'^course/', include('courses.urls', namespace='course')), # 个人中心相关URL配置 url(r'^users/', include('users.urls', namespace='users')), # 配置上传文件的访问处理函数 url('^media/(?P<path>.*)/$', serve, {'document_root': MEDIA_ROOT}),
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.conf import settings from django.conf.urls.static import static from django.views.static import serve from users.views import index,LeaveMsgView,LoginView,RegisterView,ActiveView,ForgetPwdView,ResetPwdView,ModifyPwdView from user_operations.views import LikeView urlpatterns = [ path('admin/', admin.site.urls), path('ckeditor',include('ckeditor_uploader.urls')), path('captcha/',include('captcha.urls')), path('',index,name='index'), path('gbook/',LeaveMsgView.as_view(),name='gbook'), path('blogs/',include('blogs.urls','blogs')), re_path(r'^media/(?P<path>.*)$',serve,{'document_root':settings.MEDIA_ROOT}), path('login/',LoginView.as_view(),name='login'), path('register/',RegisterView.as_view(),name='register'), path('active/<str:active_code>',ActiveView.as_view(),name='active'), path('forgetpwd/',ForgetPwdView.as_view(),name='forget_pwd'), path('reset/<str:active_code>',ResetPwdView.as_view(),name='reset_pwd'), path('modifypwd/',ModifyPwdView.as_view(),name='modify_pwd'), path('operation/',include('user_operations.urls','operation')), ] urlpatterns += static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)
from django.conf.urls import url, include from django.contrib import admin import xadmin import DjangoUeditor import os from django.conf.urls.static import static from djangoblog import settings from django.views.static import serve from users.views import RegisterView, LoginView, LogoutView, ActiveView from blogs.views import IndexView from djangoblog.settings import MEDIA_ROOT urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^xadmin/', xadmin.site.urls), url(r'^index/$', IndexView.as_view(), name='index'), url(r'^register/', RegisterView.as_view(), name='register'), url(r'^login/', LoginView.as_view(), name='login'), url(r'^logout/', LogoutView.as_view(), name='logout'), url(r'^active/(?P<active_code>\w+)/$', ActiveView.as_view(), name='active'), url(r'^blog/', include('blogs.urls', namespace='blog')), url(r'^ueditor/', include('DjangoUeditor.urls')), url(r'^media/(?P<path>.*)$', serve, {'document_root': MEDIA_ROOT}), ] if settings.DEBUG: media_root = os.path.join(settings.BASE_DIR, settings.MEDIA_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root=media_root)
from django.views.generic import TemplateView from users.views import LoginView, RegisterView, ActiveView, ForgetPwdView, ResetPwdView, ModifyPwdView, LogoutView, IndexView from organization.views import OrgListView # from django.contrib import admin import xadmin from django.views.static import serve from studyonline.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('^captcha/', include('captcha.urls')), url('^active/(?P<active_code>.*)/$', ActiveView.as_view(), name="active"), # url('^flash/(?P<query_str>.*)/$', Flash.as_view(), name="flash"), url('^forgetpwd/$', ForgetPwdView.as_view(), name="forgetpwd"), url('^resetpwd/(?P<reset_code>.*)/$', ResetPwdView.as_view(), name="resetpwd"), url('^modifypwd/$', ModifyPwdView.as_view(), name="modifypwd"), url(r'^media/(?P<path>.*)$', serve, {"document_root": MEDIA_ROOT}), # 配置上传文件的访问处理函数 # url(r'^static/(?P<path>.*)$', serve, {"document_root": STATIC_ROOT}), url('^org/', include('organization.urls', namespace='org')), url('^course/', include('courses.urls', namespace='course')), # url('^users/', include('users.urls', namespace='users')), ] # 全局404配置
import xadmin from django.views.generic import TemplateView from django.views.static import serve from django.views.generic.base import RedirectView from users.views import LoginView, RegisterView, ActiveView, UpdatePasswordView, ResetPasswordView from courseonline.settings import MEDIA_ROOT from core.views import LogoutView, IndexView urlpatterns = [ url(r'^$', IndexView.as_view(), name='index'), url(r'^index.html$', IndexView.as_view(), name='index_html'), url(r'^login.html$', LoginView.as_view(), name='login'), url(r'^logout$', LogoutView.as_view(), name='logout'), url(r'^register.html$', RegisterView.as_view(), name='register'), url(r'^active', ActiveView.as_view(), name='active'), url(r'^password/110$', UpdatePasswordView.as_view(), name='find_password'), url(r'^password/find', ResetPasswordView.as_view(), name='reset_password'), url(r'^favicon\.ico$', RedirectView.as_view(url='/static/img/favicon.ico')), url(r'^teacher/', include('operation.urls', namespace='teacher'), name='teacher'), url(r'^org/', include('orgzation.urls', namespace='org'), name='orglist'), url(r'^course/', include('courses.urls', namespace='course'), name='course'), url(r'^search/', include('core.urls', namespace='search'), name='core'), url(r'^user/', include('users.urls', namespace='user'), name='user'), url(r'^test/', include('tests.urls', namespace='test'), name='test'), # 后台管理 url(r'^xadmin/', xadmin.site.urls), # 处理静态文件 # url(r'^static/(?P<path>.*)', serve, {"document_root": STATIC_ROOT}), # 在DEBUG为False时,且没有使用Apache/Nginx部署时,需要django处理静态文件的传输
The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/2.0/topics/http/urls/ 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.contrib import admin from django.urls import path, include from users.views import ActiveView, ResetView, LoginView from django.views.generic import TemplateView urlpatterns = [ path('', LoginView.as_view(), name='index'), path('admin/', admin.site.urls), path('compare/', include('compare.urls'), name='compare'), path('users/', include('users.urls'), name='users'), path('schools/', include('schools.urls'), name='schools'), path('active/<slug:active_code>/', ActiveView.as_view(), name='active'), path('reset/<slug:reset_code>/', ResetView.as_view(), name='reset'), path('search/', TemplateView.as_view(template_name='search_method.html'), name='search_method'), ]
""" 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 LoginView, LogoutView, IndexView, RegisterView, ActiveView, ForgetPwdView, ResetView, ModifyPwdView from MxOnline.settings import MEDIA_ROOT urlpatterns = [ url(r'^xadmin/', xadmin.site.urls), url(r'^$', IndexView.as_view(), name="index"), 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'^active/(?P<active_code>.*)/$', ActiveView.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'^modify_pwd/$', ModifyPwdView.as_view(), name="modify_pwd"), url(r'^captcha/', include('captcha.urls')), # 课程机构url配置 url(r'^org/', include('organization.urls', namespace='org')), # 配置上传文件的访问处理函数 url(r'^media/(?P<path>.*)$', serve, {'document_root': MEDIA_ROOT}), # url(r'^static/(?P<path>.*)$', serve, {'document_root': STATIC_ROOT}), # 课程机构url配置 url(r'^course/', include('courses.urls', namespace='course')),
from django.conf.urls import url # from users.views import register from users.views import Register, ActiveView,LoginView, LoginoutView, AddressView, UserinfoView urlpatterns = [ # url(r'^register/$', register, name='register') url(r'^register/$', Register.as_view(), name='register'), url(r'^active/(?P<token>.+)$', ActiveView.as_view(), name='active'), url(r'^login/$',LoginView.as_view(), name='login'), url(r'^logout/$', LoginoutView.as_view(), name='logout'), url(r'^address/$', AddressView.as_view(), name='address'), url(r'^userinfo/$', UserinfoView.as_view(), name='userinfo') ]
from users.views import LoginView, RegisterView, ActiveView, ForgetPasswordView, LogoutView, UserVerifyView from users.views import PasswordResetView import xadmin from django.urls import path from django.views.static import serve from .settings import MEDIA_ROOT from publisher.views import UserFavView, TeachersView, TeacherDetailView # from .settings import STATIC_ROOT urlpatterns = [ url(r'^admin/', xadmin.site.urls), url(r'^$', IndexView.as_view(), name="index"), url(r'^login/', view=LoginView.as_view(), name="login"), url(r"^register/", view=RegisterView.as_view(), name="register"), url(r'^captcha/', include('captcha.urls')), path("user_active/<code>/", view=ActiveView.as_view()), path("forget_pwd/", view=ForgetPasswordView.as_view(), name="forget_password"), path("logout/", view=LogoutView.as_view(), name="logout"), path("password_forget/<code>", view=UserVerifyView.as_view()), path("password_reset/", view=PasswordResetView.as_view(), name="password_reset"), path("publisher/", include("publisher.urls")), url(r"^media/(?P<path>.*)", serve, {"document_root": MEDIA_ROOT}), path("user_collect/", view=UserFavView.as_view(), name="user_fav"), # course path("course/", include("course.urls")), path('teachers/', TeachersView.as_view(), name="teachers"), path('teacher_detail/<int:teacher_id>/',
from django.urls import path, include, re_path from django.views.generic import TemplateView from django.views.static import serve from datetime import timedelta from edut_online.settings import MEDIA_ROOT import xadmin from users.views import LoginView, RegisterView, ActiveView, ForgetPwdView, ResetPwdView, ModifyPwdView, LogoutView, IndexView urlpatterns = [ path('xadmin/', xadmin.site.urls), path('', IndexView.as_view(), name='index'), path('register/', RegisterView.as_view(), name='register'), path('logout/', LogoutView.as_view(), name='logout'), path('login/', LoginView.as_view(), name='login'), path('captcha/', include('captcha.urls')), path('active/<str:active_code>/', ActiveView.as_view(), name='user_active'), path('forget/', ForgetPwdView.as_view(), name='forget_pwd'), path('reset/<str:reset_code>/', ResetPwdView.as_view(), name='reset_pwd'), path('modify_pwd/', ModifyPwdView.as_view(), name='modify_pwd'), #课程机构url配置 path('org/', include(('organizations.urls', 'organizations'), namespace="org")), #配置上传文件的访问处理函数 re_path(r'media/(?P<path>.*)$', serve, {'document_root': MEDIA_ROOT}), # re_path(r'static/(?P<path>.*)$', serve, {'document_root': STATIC_ROOT}), # 课程url配置 path('course/', include(('courses.urls', 'courses'), namespace="course")), #个人中心url配置 path('users/', include(('users.urls', 'users'), namespace="user")),
from XMJonline.settings import MEDIA_ROOT # STATIC_ROOT from users.views import IndexView import xadmin urlpatterns = [ # url(r'^admin/', admin.site.urls), url(r'^xadmin/', xadmin.site.urls), url('^$', IndexView.as_view(), name='index'), #处理静态文件?什么意思 这里的功能好像是不需要写视图函数,直接将index.html文件传到浏览器 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<code>.*)/$', ActiveView.as_view(), name='user_active'), #密码重置 url(r'^reset/(?P<code>.*)/$', ResetView.as_view(), name='user_reset'), url(r'^modify_pwd/$', ModifyPwdView.as_view(), name='modify_pwd'), url(r'^forget/$', ForgetPwdView.as_view(), name='forget_pwd'), #课程机构url配置 url(r'^org/', include('organization.urls', namespace='org')), # #课程机构首页 # url(r'^org_list/$',OrgView.as_view(),name='org_list'), # 课程相关url配置 url(r'^course/', include('courses.urls', namespace='course')), # 用户相关url配置 url(r'^users/', include('users.urls', namespace='users')),