Answer the question
In order to leave comments, you need to log in
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
wrote something weird...
#поле из формы
phone = form.cleaned_data["phone"]
# текущий пользователь, Anonymous либо инстант User-а
# обязательно проверить авторизацию!
user = self.request.user
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question