diff --git a/.gitignore b/.gitignore index 1f1b385..158121c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,6 @@ env/ db.sqlite3 .DS_Store .env +.env.prod venv/ mguvenv/ diff --git a/accounts/models.py b/accounts/models.py index 669e810..f43bd8b 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -19,7 +19,7 @@ class User(AbstractUser): reliability = models.IntegerField(default=100) USERNAME_FIELD = "email" - REQUIRED_FIELDS = [] + REQUIRED_FIELDS = ["name"] def __str__(self): return self.name diff --git a/accounts/serializers.py b/accounts/serializers.py index fd344e4..cca8254 100644 --- a/accounts/serializers.py +++ b/accounts/serializers.py @@ -49,7 +49,7 @@ def create(self, validated_data): # 로그인 시리얼라이저 class LoginSerializer(serializers.Serializer): - username = serializers.EmailField(required=True) + email = serializers.EmailField(required=True) # write_only=True 를 통해 클라이언트->서버 만 가능하도록 설정 password = serializers.CharField(required=True, write_only=True) diff --git a/accounts/views.py b/accounts/views.py index 521b38d..47055b8 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -16,6 +16,7 @@ class LoginView(generics.GenericAPIView): def post(self, request): serializer = self.get_serializer(data=request.data) - serializer.is_valid(raise_exception=True) - token = serializer.validated_data - return Response({"token": token.key}, status=status.HTTP_200_OK) + if serializer.is_valid(): + token = serializer.validated_data + return Response({"token": token.key}, status=status.HTTP_200_OK) + return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) diff --git a/requirements.txt b/requirements.txt index f94865d..e11942c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,3 +8,4 @@ python-decouple==3.8 setuptools==70.0.0 sqlparse==0.5.0 typing_extensions==4.12.2 +gunicorn==22.0.0