from django.conf.urls import patterns, include, url from rest_framework import routers from login.views import AccountViewSet, IndexView, LoginView, LogoutView import logging router = routers.SimpleRouter() router.register(r"accounts", AccountViewSet) log = logging.getLogger("someLogger") log.setLevel(logging.DEBUG) # create console handler with a higher log level ch = logging.StreamHandler() ch.setLevel(logging.DEBUG) # create formatter and add it to the handlers formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") ch.setFormatter(formatter) # add the handlers to the logger log.addHandler(ch) log.info(router.urls) urlpatterns = patterns( "", url(r"^api/v1/", include(router.urls)), url(r"^api/v1/auth/login/$", LoginView.as_view(), name="login"), url(r"^api/v1/auth/logout/$", LogoutView.as_view(), name="logout"), url("^.*$", IndexView.as_view(), name="index"), )
https://docs.djangoproject.com/en/2.2/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 login.views import LoginView, IndexView from appatencion.views import menuView from django.conf import settings urlpatterns = [ path('admin/', admin.site.urls), path('', LoginView.as_view(), name='login'), path('index/', IndexView.as_view(), name='index'), path('menu/', menuView.as_view(), name='menu'), ] if settings.DEBUG: from django.conf.urls.static import static urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
from django.urls import include from django.contrib.staticfiles.urls import staticfiles_urlpatterns from login.views import IndexView urlpatterns = [ path('admin/', admin.site.urls), path('', views.index, name='index'), path('index/', views.index, name='index'), path('login1/', views.login2, name='login2'), path('register/', views.register, name='register'), path('logout/', views.logout, name='logout'), path('captcha/', include('captcha.urls')), # path('^ajax_val/', views.ajax_val, name='ajax_val'), path('refresh_captcha/', views.refresh_captcha, name='refresh_captcha'), path('login/', IndexView.as_view(), name='login'), #get与post请求路径 path('confirm/', views.user_confirm), path('add_book/', ve.add_book, name='add_book'), path('add_book/index/', views.index), path('add_img/', ve.add_img, name='add_img'), path('add_img/index/', views.index), path('book_list/', ve.book_list, name='book_list'), path('book_list/<str:category>/', ve.book_list, name='book_list'), path('book_detail/<book_id>/', ve.book_detail, name='book_detail'), path('test/', views.book_detail, name='test'), # path('book_detail/',ve.book_detail,name='book_detail'), # path('book_detail/.*',ve.book_detail,name='book_detail'), ] # admin后台打开
Examples: 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.contrib import admin from login.views import IndexView, LoginView, LogoutView, RegisterView from login.views import UserActiveView urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^$', IndexView.as_view(), name='index'), url(r'^index/$', 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<verify_code>.*)/$', UserActiveView.as_view(), name='user_active'), # 图片验证码 url(r'^captcha/', include('captcha.urls')), ]
from django.conf.urls import patterns, include, url from django.contrib import admin from login.views import IndexView admin.autodiscover() urlpatterns = patterns('', url('', include('social.apps.django_app.urls', namespace='social')), url(r'^admin/', include(admin.site.urls)), url(r'^$', IndexView.as_view()), url(r'^logout/$', 'login.views.log_out'), url(r'^deauthorize/$', 'login.views.deauthorize'), )
"""ayomi URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/3.1/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 django.conf.urls import url from login.views import LoginView from login.views import IndexView urlpatterns = [ path('admin/', admin.site.urls), path('profile/', LoginView.as_view(), name="profile"), path('', IndexView.as_view(), name="index"), url('^', include('django.contrib.auth.urls')) ]
from django.conf.urls import url, include from login.views import IndexView urlpatterns = [ url(r'^$', IndexView.as_view(), name='login'), ]
from django.conf.urls import include, url from login.views import IndexView urlpatterns = [ url(r'^$', IndexView.as_view(),name="index"), ]