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 import settings from django.conf.urls import url, include from django.views.static import serve from django.conf.urls.static import static from apps.account.views import LogoutView, LoginView urlpatterns = [ url(r'^static/(?P<path>.*)$', serve, {'document_root': settings.STATIC_ROOT}), url(r'', include('account.urls', namespace='account')), url(r'assets/', include('assets.urls', namespace='assets')), url(r'wiki/', include('wiki.urls', namespace='wiki')), url(r'^login/$', LoginView.as_view(), name='login'), url(r'^logout/$', LogoutView.as_view(), name='logout'), ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) if settings.DEBUG: import debug_toolbar urlpatterns.append(url(r'^__debug__/', include(debug_toolbar.urls)))
from django.conf.urls import url, include from django.contrib import admin from django.conf import settings from django.conf.urls.static import static from apps.account.views import RegisterView, LoginView, LogoutView, ListCities from apps.taggit_autocomplete.views import ListTags from apps.website.views import IndexView, RestaurantView, CreateOrderView, OrderListView, ReviewCreateView, \ CancelOrderView urlpatterns = [ url(r'^admin/doc/', include('django.contrib.admindocs.urls')), url(r'^admin/', admin.site.urls), url(r'^nested_admin/', include('nested_admin.urls')), url(r'', include('taggit_live.urls')), url(r'^list_tags/$', ListTags.as_view(), name='list_tags'), url(r'^list_cities/$', ListCities.as_view(), name='list_cities'), url(r'^orders/$', OrderListView.as_view(), name='orders'), url(r'^order/(?P<pk>\d+)/$', CancelOrderView.as_view(), name='cancel_order'), url(r'^restaurant/(?P<pk>\d+)/$', RestaurantView.as_view(), name='restaurant'), url(r'^restaurant/(?P<restaurant_pk>\d+)/review/$', ReviewCreateView.as_view(), name='review'), url(r'^restaurant/(?P<restaurant_pk>\d+)/meal/(?P<meal_pk>\d+)$', CreateOrderView.as_view(), name='order'), url(r'^$', 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"), ]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
from django.contrib import admin from django.urls import path, include from django.views.generic import TemplateView from apps.account.views import LoginView, SignupView from apps.apply.views import ApplyView, ApplyListView, ApplyDetailView from django.conf.urls.static import static from django.conf import settings urlpatterns = [ path('admin/', admin.site.urls), path('', TemplateView.as_view(template_name='index.html')), path('login/', LoginView.as_view()), path('signup/', SignupView.as_view()), # path('apply/', ApplyView.as_view()), path('account/', include('django.contrib.auth.urls')), path('list/', ApplyListView.as_view()), path('list/<int:pk>/', ApplyDetailView.as_view()) ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
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,re_path,include from django.conf import settings from django.views.static import serve from apps.account.views import LoginView urlpatterns = [ path('admin/', admin.site.urls), path('account/', include("apps.account.urls")), path('cmdb/', include("apps.cmdb.urls")), path('sqlmng/', include("apps.sqlmng.urls")), path('', LoginView.as_view(), name='login'), re_path('media/(?P<path>.*)$', serve,{"document_root":settings.MEDIA_ROOT}), re_path('static/(?P<path>.*)$', serve,{"document_root":settings.STATIC_ROOT}), ] handler404 = 'apps.account.views.page_not_found' handler500 = 'apps.account.views.page_error'
from apps.account.views import ( LoginView, RegisterView, ProfileView, ProfileSettingsView, ProfileOrdersView, ProfileDeliveryView, ProfilePaymentView, ProfilePaymentEdit, ) urlpatterns = [ url( r'^login/$', LoginView.as_view(), name='login', ), url( r'^logout/$', login_required(LogoutView.as_view(next_page='/')), name='logout', ), url( r'^register/$', RegisterView.as_view(), name='register', ), url( r'^$', login_required(ProfileView.as_view()),