Created
June 27, 2021 02:21
-
-
Save sankalpjonn/4de392eca0e0f7c923525dae03f1eacb to your computer and use it in GitHub Desktop.
This file contains hidden or 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 rest_framework import generics | |
from .models import Record | |
from django.http import Http404 | |
class RecordRetrieveView(generics.RetrieveAPIView): | |
serializer_class = RecordSerializer | |
def get_object(self): | |
try: | |
return Record.objects.get(id=self.request.query_params['id']) | |
except Record.DoesNotExist: | |
raise Http404() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment