"""
接口访问地址: /user/mobile/(?P<mobile>1[3-9]\d{9})/
"""
from rest_framework import status
class MobileAPIView(APIView):
def get(self,request,mobile):
"""验证码手机号唯一性"""
#1. 根据手机号到数据库里面查找用户,返回结果
try:
User.objects.get(mobile=mobile)
return Response({"status": False}, status=status.HTTP_400_BAD_REQUEST)
except User.DoesNotExist:
return Response({"status": True}, status=status.HTTP_200_OK)
from django.urls import path,re_path
from rest_framework_jwt.views import obtain_jwt_token
from . import views
urlpatterns = [
path("login/", obtain_jwt_token),
path("captcha/", views.GeetestCaptchaAPIView.as_view()),
path("", views.UserAPIView.as_view()),
re_path("mobile/(?P<mobile>1[3-9]\d{9})/", views.MobileAPIView.as_view()),
]