Hello, I have this view
# Last Audit By Line
class LastAuditByLine(APIView):
def get_object(self, id):
try:
return Line.objects.get(id=id)
except:
print ("TEST")
#raise Http404
@swagger_auto_schema(
operation_summary="Get Last Audit By Line",
operation_description="Get Last Audit By Line",
responses={
status.HTTP_200_OK: response_200(AuditSerializer(many=True)),
status.HTTP_404_NOT_FOUND: response_404(),
},
)
def get(self, request, id, format=None):
if self.get_object(id):
audit = Audit.objects.filter(line=id).order_by("-audit_date")[:1]
serializer = AuditSerializer(audit, many=True)
return JsonResponse(serializer.data, safe=False)```
I want to raise a message like "This line does not exists" in the exception. If I use print method I have this error:
AssertionError at /fjbe_prod_panel/api/audit/2
Expected a Response, HttpResponse or HttpStreamingResponse to be returned from the view, but received a `<class 'NoneType'>```