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?


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a4cb1a33-8805-4d36-b663-9bdabe9c2928%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to