Skip to content

Commit 330a396

Browse files
committed
Added login API
1 parent 6f1ffe3 commit 330a396

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

profiles_api/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88

99
urlpatterns = [
1010
path('hello-view/', views.HelloApiView.as_view()),
11+
path('login/', views.UserLoginApiView.as_view()),
1112
path('', include(router.urls))
1213
]

profiles_api/views.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
from rest_framework.response import Response
33
from rest_framework import status, viewsets, filters
44
from rest_framework.authentication import TokenAuthentication
5+
from rest_framework.authtoken.views import ObtainAuthToken
6+
from rest_framework.settings import api_settings
57

68
from profiles_api import serializers
79
from profiles_api import models
@@ -109,3 +111,7 @@ class UserProfileViewSet(viewsets.ModelViewSet):
109111

110112
# once creating model serializer Django already knows the actions
111113
# ex: list, craete, update....
114+
115+
class UserLoginApiView(ObtainAuthToken):
116+
"""Hadnle creating user authentication token"""
117+
renderer_classes = api_settings.DEFAULT_RENDERER_CLASSES

0 commit comments

Comments
 (0)