Created
July 4, 2023 17:38
-
-
Save mansha99/d11958e9cfa5c56c955810ee4c411e14 to your computer and use it in GitHub Desktop.
notice_app/notices/views/notice.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.http import JsonResponse | |
from ..models import Notice | |
from rest_framework import permissions | |
from rest_framework.decorators import api_view | |
from rest_framework.decorators import permission_classes | |
from rest_framework.permissions import IsAuthenticated | |
@api_view(['GET']) | |
@permission_classes([permissions.IsAuthenticated]) | |
def listAllNotices(request): | |
output = {} | |
# No database activity actually occurs until | |
# we do something to evaluate the queryset. | |
# list() forces evaluation of a QuerySet | |
output["list"] = list(Notice.objects.values()) | |
return JsonResponse(output) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment