示例#1
0
from django.contrib import admin
from django.urls import path, include

from apps.common.views import HomeView, SignUpView, DashboardView
from apps.myblog.views import PostCreateView, PostListView, PostDetailView, PostUpdateView, PostDeleteView
from apps.userprofile.views import ProfileUpdateView, ProfileView, ProfileViewFriend
from apps.userprofile.apis import (LoginView, LogoutView)
# from apps.common.apis import RegisterAPI, LoginAPI
from apps.myblog.apis import GenericAPIView, GenericAPIViewDetail, GenericAPIViewCreatePost
from django.contrib.auth import views as auth_views
from knox import views as knox_views
from rest_framework.authtoken import views

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', HomeView.as_view(), name='home'),
    path('profile-update/', ProfileUpdateView.as_view(),
         name='profile-update'),
    path('profile/', ProfileView.as_view(), name='profile'),
    path('profile/<str:username>',
         ProfileViewFriend.as_view(),
         name='profile-friend'),
    path('register/', SignUpView.as_view(), name='register'),
    path('login/',
         auth_views.LoginView.as_view(template_name='common/login.html'),
         name='login'),
    path('logout/',
         auth_views.LogoutView.as_view(next_page='home'),
         name='logout'),
    path('change-password/',
         auth_views.PasswordChangeView.as_view(
示例#2
0
    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
from django.urls import reverse_lazy
from apps.common.views import HomeView, SignUp, DashboardView, ProfileUpdateView, ProfileView
from django.contrib.auth import views as auth_views
urlpatterns = [
    path('admin/', admin.site.urls),
    path('', HomeView.as_view(), name="home"),
    path('registration/', SignUp.as_view(), name='registration'),
    path("login/",
         auth_views.LoginView.as_view(template_name="common/login.html"),
         name="login"),
    path("logout/",
         auth_views.LogoutView.as_view(next_page='home'),
         name="logout"),
    path("dashboard/", DashboardView.as_view(), name="dashboard"),
    path("changepassword/",
         auth_views.PasswordChangeView.as_view(
             template_name="common/changepassword.html",
             success_url=reverse_lazy('home')),
         name="changepassword"),
    path('password-reset/',
         auth_views.PasswordResetView.as_view(