M
M
ma3xak2018-06-26 04:57:50
Django
ma3xak, 2018-06-26 04:57:50

Get field value?

I'm trying to make a confirmation of registration by the user, an activation code should come to the phone number. But ran into a problem. Can't get the value of a user-entered field

class RegisterFormView(FormView):
    form_class = UserCreate
    success_url = "/sms"
    template_name = 'accounts/register.html'
    def form_valid(self, form):
        inv_assets = User.objects.all()
        fields = User._meta.get_fields()
        x = random.randint(1000, 9999)
        code = str(x)
        phone = User.phone
        number = str(phone)
        smsc = SMSC()
        ...
        r = smsc.send_sms(number, "Для подтверждения регистрации введите этот код: " + code, sender= "sms")
        print(number)
        print(code)
        form.save()
        return super(RegisterFormView, self).form_valid(form)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Kopitsa, 2018-07-16
@dkopitsa

wrote something weird...

#поле из формы
phone = form.cleaned_data["phone"]
# текущий пользователь, Anonymous либо инстант User-а
# обязательно проверить авторизацию!
user = self.request.user

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question