from django.urls import path from accounts.views import (AccountLogin, AccountLogout, AccountRegister, user_delete) app_name = 'accounts' urlpatterns = [ path('login/', AccountLogin.as_view(), name='login'), path('logout/', AccountLogout.as_view(), name='logout'), path('delete/', user_delete, name='delete'), path('register/', AccountRegister.as_view(), name='register'), ]
from django.urls import path from rest_framework_simplejwt import views as jwt_views from accounts.views import ( AccountLogin, AccountRegistration, AccountList, AccountDetail, ) urlpatterns = [ path('token/obtain/', jwt_views.TokenObtainPairView.as_view(), name="token-create"), path('token/refresh/', jwt_views.TokenRefreshView.as_view(), name="token-refresh"), path('login/', AccountLogin.as_view(), name="account-login"), path('register/', AccountRegistration.as_view(), name="account-registration"), path('accounts/', AccountList.as_view(), name="account-list"), path(r'accounts/<int:account_id>/', AccountDetail.as_view(), name='account-update'), ]
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 accounts.views import AccountLogin, AccountViewSet from accounts.views_social import oauth2_signin from rest_framework import routers router = routers.DefaultRouter() # router.register(r'users', UserViewSet) router.register(r'user', AccountViewSet) urlpatterns = [ path('admin/', admin.site.urls), path('o/', include('oauth2_provider.urls', namespace='oauth2_provider')), path('auth/user-login/', AccountLogin.as_view(), name='user-login'), path('api/social/google-oauth2/', oauth2_signin), #Restframework path('api/', include(router.urls)), path('api-auth/', include('rest_framework.urls')), path('auth/', include('rest_framework_social_oauth2.urls')), ]
from django.urls import path from accounts.views import AccountRegistration, AccountRegistrationSuccess, AccountLogin, AccountLogout app_name = "accounts" urlpatterns = [ path("accounts/register/", AccountRegistration.as_view(), name="register"), path("accounts/register-success/", AccountRegistrationSuccess.as_view(), name="register-success"), path("accounts/login/", AccountLogin.as_view(), name="login"), path("accounts/logout/", AccountLogout.as_view(), name="logout") ]