Skip to content

Commit

Permalink
feat: user detail view
Browse files Browse the repository at this point in the history
  • Loading branch information
Shavkatjon-O committed Aug 22, 2024
1 parent 31d7c71 commit d79070e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
9 changes: 9 additions & 0 deletions apps/users/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,12 @@ def create(self, validated_data):
return user
except Exception as e:
raise serializers.ValidationError(str(e))


class UserSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields = (
"id",
"email",
)
4 changes: 3 additions & 1 deletion apps/users/urls.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from django.urls import path
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView
from apps.users.views import SignupView
from apps.users.views import SignupView, UserDetailView


urlpatterns = [
path("token/", TokenObtainPairView.as_view(), name="token_obtain_pair"),
path("token/refresh/", TokenRefreshView.as_view(), name="token_refresh"),
path("signup/", SignupView.as_view(), name="signup"),
path("user/", UserDetailView.as_view(), name="user"),
]
5 changes: 5 additions & 0 deletions apps/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@
class SignupView(generics.CreateAPIView):
queryset = User.objects.all()
serializer_class = SignupSerializer


class UserDetailView(generics.RetrieveAPIView):
queryset = User.objects.all()
serializer_class = SignupSerializer
2 changes: 1 addition & 1 deletion core/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
"DEFAULT_AUTHENTICATION_CLASSES": (
"rest_framework_simplejwt.authentication.JWTAuthentication",
),
"DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.AllowAny",),
"DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",),
}

SIMPLE_JWT = {
Expand Down

0 comments on commit d79070e

Please sign in to comment.