From 31423c6a7cf9c9861f33a1726327829ed88043df Mon Sep 17 00:00:00 2001 From: Radi Mustafa Date: Sat, 12 Sep 2020 15:55:09 +0200 Subject: [PATCH] fix: handle APIException when rest_framework is not installed --- comment/exceptions.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/comment/exceptions.py b/comment/exceptions.py index e734b3e..ebbe73b 100644 --- a/comment/exceptions.py +++ b/comment/exceptions.py @@ -1,9 +1,11 @@ -from rest_framework.exceptions import APIException -from rest_framework.status import HTTP_400_BAD_REQUEST +try: + from rest_framework.exceptions import APIException +except ModuleNotFoundError: + APIException = Exception class CommentBadRequest(APIException): - status_code = HTTP_400_BAD_REQUEST + status_code = 400 default_detail = 'Bad Request' def __init__(self, detail=None, status_code=None):