profiles: init

This commit is contained in:
2023-10-29 21:09:38 +01:00
parent 246213c5b8
commit 54cc1b1705
7 changed files with 51 additions and 2 deletions

View File

@ -1,3 +1,21 @@
from django.shortcuts import render
from django.views import View
from django.http import HttpResponse, HttpRequest
from django.contrib.auth.models import User
from django.http import JsonResponse
from .status_code import *
from .models import Profile
# Create your views here.
class ProfilePage(View):
def get(self, request: HttpRequest, id: int):
query: QuerySet = Profile.objects.filter(pk=id)
if (not query.exists()):
return HttpResponse(PROFILE_NOT_FOUND)
profile: Profile = Profile.objects.get(pk=id)
return JsonResponse({'username': profile.user.username,
'title': profile.title})