i'm making an OTP app using class based views. the bottom is the class for generating and sending OTP to a phone number. the template works good and when i press the submit button in my html form it sends a post request and it returns response: 'phone number is not given in post req' so the template and API works! but the {{form}} in the html template doesn't work so i can't send the OTP to the number submitted in the form.
so what am i doing wrong? forms.py exists in my project with 1 field
class ValidatePhoneSendOTP(APIView,TemplateView):
template_name = 'accs/reg.html'
def post(self, request, *args, **kwargs):
form = PhoneRegForm(request.POST)
phone_number = request.data.get('phone')
if phone_number:
phone = str(phone_number)
user = User.objects.filter(phone_number__iexact = phone)
if user.exists():
return Response({
'status': False,
'detail': 'user exists'
})
.
.
.
.
.
.
.
.
else:
return Response({
'status' : False,
'detail' : 'phone number is not given in post req'
})i tried to pass FormView in the class after the APIView,TemplateView but i couldn't get that to work.
what am i doing wrong?