本文整理汇总了Python中accounts.models.User.phone_number方法的典型用法代码示例。如果您正苦于以下问题:Python User.phone_number方法的具体用法?Python User.phone_number怎么用?Python User.phone_number使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类accounts.models.User
的用法示例。
在下文中一共展示了User.phone_number方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from accounts.models import User [as 别名]
# 或者: from accounts.models.User import phone_number [as 别名]
def post(self, request):
form = RegistrationForm(data=request.POST)
response = HttpResponseRedirect('/')
if form.is_valid():
user = User()
year = request.POST['birthdate_year']
month = request.POST['birthdate_month']
day = request.POST['birthdate_day']
date_of_birth = year+'-'+month+'-'+day
user.birthday = date_of_birth
user.email = form.cleaned_data['email']
user.role = 'client'
user.first_name = form.cleaned_data['first_name']
user.phone_number = ''
user.zip_code = form.cleaned_data['zip_code']
user.last_name = form.cleaned_data['last_name']
user.set_password(form.cleaned_data['password'])
user.save()
confirm_register_mail(request, user.email, user.first_name, user.last_name, user.zip_code)
new_user = authenticate(email=form.cleaned_data['email'],
password=form.cleaned_data['password'],
)
login(request, new_user)
messages.success(request, "You have registered successfully.")
else:
response.set_cookie('registr_error', 'error')
cache.set('registartion_error', RegistrationForm(request.POST))
return response
示例2: create
# 需要导入模块: from accounts.models import User [as 别名]
# 或者: from accounts.models.User import phone_number [as 别名]
def create(self, validated_data):
user = User()
user.set_password(validated_data["password"])
user.email = validated_data['email']
user.first_name = validated_data['first_name']
user.last_name = validated_data['last_name']
user.phone_number = validated_data['phone_number']
return user