from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import status

from diaries.models import Diary


class DiaryDetailAPIView(APIView):

    def get(self, request, *args, **kwargs):

        year = kwargs.get("year")
        month = kwargs.get("month")
        day = kwargs.get("day")
        datetime = year + "/" + month + "/" + day
        diary = request.user.diary_set.get_or_none(datetime=datetime)

        if diary:
            # Diary is exist
            content = diary.content
        else:
            # Diary is not exist
            content = ""

        return Response(
            status=status.HTTP_201_CREATED,
            data={
                "content": content,
            },
        )

    def delete(self, request, *args, **kwargs):

        year = kwargs.get("year")
        month = kwargs.get("month")
        day = kwargs.get("day")
        datetime = year + "/" + month + "/" + day
        diary = request.user.diary_set.get_or_none(datetime=datetime)

        if diary:
            # Diary is exist
            diary.delete()

        return Response(
            status=status.HTTP_201_CREATED,
            data={
            },
        )

@@ -118,42 +118,8 @@
 us%0A%0A
-from diaries.models import Diary%0A%0A
 %0Acla
@@ -322,39 +322,31 @@
 e = year
- + %22/%22 + month + %22/%22 + 
++%22/%22+month+%22/%22+
 day%0A    

fix DiaryDetailAPIView: delete unnecessary import code