ft_transcendence/srcs/profiles/views.py

19 lines
673 B
Python
Raw Permalink Normal View History

2023-11-23 10:43:30 -05:00
from django.http import HttpRequest
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import permissions, status
from .models import ProfileModel
# Create your views here.
class ProfileView(APIView):
permission_classes = (permissions.AllowAny,)
def get(self, request: HttpRequest, pk: int):
profile: ProfileModel = ProfileModel.objects.get(pk=pk)
if (profile is None):
return Response(status=status.HTTP_404_NOT_FOUND)
return Response(status=status.HTTP_200_OK, data={'name': profile.user.username,
'title': profile.title})