from django.urls import path from users.views import SignUpView,HomeView urlpatterns=[ path('',HomeView.as_view(),name='home'), path('signup/',SignUpView.as_view(),name='signup'), ]
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") ]
from rest_framework import routers from repositories.views import (CommitViewSet, GithubHookListener, RepositoryViewSet, UsersRepositoryList) from users.views import HomeView, LogoutView, UserViewSet router = routers.DefaultRouter() router.register(r'users', UserViewSet) router.register(r'commits', CommitViewSet, basename='commits') router.register(r'repositories', RepositoryViewSet, basename='repositories') urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^jsreverse/$', django_js_reverse.views.urls_js, name='js_reverse'), url(r'^$', RedirectView.as_view(url='rfeed')), url(r'^rfeed/', HomeView.as_view(), name='home'), url(r'^logout/$', LogoutView.as_view(), name='logout'), url(r'^oauth/', include('social_django.urls', namespace='social')), url(r'^api/', include(router.urls)), url(r'^webhook/$', GithubHookListener.as_view(), name='webhooklistener'), url(r'^users/repositories/$', UsersRepositoryList.as_view(), name='userRepositories') ] if settings.DEBUG: import debug_toolbar urlpatterns = [ url(r'^__debug__/', include(debug_toolbar.urls)), ] + urlpatterns
from django.conf.urls import include, url from django.contrib import admin from users.views import HomeView, LogoutSessionView, UserDetailView urlpatterns = [ url(r'^$', HomeView.as_view(), name='home'), url(r'^api/login/', include('rest_social_auth.urls_session')), url(r'^api/login/', include('rest_social_auth.urls_token')), url(r'^api/logout/session/$', LogoutSessionView.as_view(), name='logout_session'), url(r'^api/user/', UserDetailView.as_view(), name="current_user"), url(r'^admin/', include(admin.site.urls)), ]
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, re_path from django.conf.urls import include from users.views import UserSignup, HomeView, activate from django.views.generic import TemplateView from album.views import AlbumUploadView from django.conf import settings from django.conf.urls.static import static from api.views import AlbumCreate urlpatterns = [ path('admin/', admin.site.urls), path('user/', include('django.contrib.auth.urls')), path("user/register/", UserSignup.as_view(), name="register"), path('', HomeView.as_view(), name="home"), 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'), re_path(r'^api-auth/', include('rest_framework.urls')), re_path(r'^rest-auth/', include('rest_auth.urls')), re_path(r'^rest-auth/registration/account-confirm-email/(?P<key>[-:\w]+)/$', TemplateView.as_view(template_name='registration/empty.html'),name='account_confirm_email'), re_path(r'^rest-auth/registration/', include('rest_auth.registration.urls')), path("album/create/", AlbumUploadView.as_view(), name="album_create"), re_path(r'^api/albums', AlbumCreate.as_view(), name='create_album'), ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
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 django.views.static import serve from community_management.settings import MEDIA_ROOT from users.views import HomeView, Captcha urlpatterns = [ path('admin/', admin.site.urls), # 系统入口 path('', HomeView.as_view(), name='index'), # 用户相关 path('api/users/', include(('users.urls', 'users'), namespace='users')), # 社团相关 path('api/community/', include(('community.urls', 'community'), namespace='community')), # 资料相关 path('api/data/', include(('data.urls', 'data'), namespace='data')), # 项目相关 path('api/projects/', include(('projects.urls', 'projects'), namespace='projects')), # 新闻活动相关 path('api/news/', include(('news.urls', 'news'), namespace='news')),
"""milo URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/3.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 HomeView urlpatterns = [ path('admin/', admin.site.urls), path('users/', include('users.urls')), path('', HomeView.as_view()), ]
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, re_path, include from users.views import HomeView from reminder.views import ReminderViewSet from users.views import UserViewSet, ProfileViewSet urlpatterns = [ path('admin/', admin.site.urls), re_path(r'^$', HomeView.as_view(), name='home'), re_path(r'^users/', include('users.urls.users', )), re_path(r'^reminders/', include('reminder.urls')), ] #api urls from rest_framework.routers import DefaultRouter router = DefaultRouter() router.register(r'reminders', ReminderViewSet) router.register(r'users', UserViewSet) router.register(r'profiles', ProfileViewSet) urlpatterns += [ re_path(r'^api/', include(router.urls)), re_path(r'^api-auth/', include('rest_framework.urls')),
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.contrib.auth import views as auth_views from django.urls import path, include from django.conf import settings from django.conf.urls.static import static from users import views as user_views from users.views import HomeView urlpatterns = [ path('admin/', admin.site.urls), path('profile/', user_views.profile, name='profile'), path('logout/', auth_views.LogoutView.as_view(template_name='users/logout.html'), name='logout'), path('', auth_views.LoginView.as_view(template_name='users/login.html'), name='login'), path('home/', HomeView.as_view(), name='home-start'), path('tobacco/', include('tobacco.urls'), name='tobacco-home'), path('api/', include('api.urls'), name='api-home'), path('lab/', include('lab.urls'), name='lab-home'), ] if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
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 import url from django.contrib import admin from django.contrib.auth.views import LoginView from django.views.generic import TemplateView from dish.views import MealCreateView from exercise.views import WorkoutCreateView from sleep.views import SleepCreateView from users.views import HomeView from weight.views import WeightCreateView urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^$', HomeView.as_view(template_name='home.html'), name='home'), url(r'^about/$', TemplateView.as_view(template_name='about.html'), name='about'), url(r'^login/$', LoginView.as_view(), name='login'), url(r'^diet/$', MealCreateView.as_view(), name='diet'), url(r'^exercise/$', WorkoutCreateView.as_view(), name='exercise'), url(r'^sleep/$', SleepCreateView.as_view(), name='sleep'), # url(r'^weight/$', WeightListView.as_view(), name='weight'), url(r'^weight/$', WeightCreateView.as_view(), name='weight'), # url(r'^restaurants/(?P<slug>[\w-]+)/$', RestaurantDetailView.as_view()), ]