本文整理汇总了Python中auth.models.User.username方法的典型用法代码示例。如果您正苦于以下问题:Python User.username方法的具体用法?Python User.username怎么用?Python User.username使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类auth.models.User
的用法示例。
在下文中一共展示了User.username方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: other_user
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import username [as 别名]
def other_user():
from auth.models import User
user = User()
user.username = 'Luke_Skywalker'
user.email = '[email protected]'
user.password = user.generate_password(password='12345678')
user.save(commit=True)
return user
示例2: user
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import username [as 别名]
def user():
from auth.models import User
user = User()
user.username = 'Darth_Vader'
user.email = '[email protected]'
user.password = user.generate_password(password='12345678')
user.save(commit=True)
return user
示例3: register_do
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import username [as 别名]
def register_do(request):
password = request.GET.get('password')
password_repeat = request.GET.get('password_repeat')
if password != password_repeat:
return HttpResponseRedirect('/auth/register')
logging.info( password)
logging.info( password_repeat)
user = User()
user.username = request.GET.get('name')
user.password = request.GET.get('password')
user.email = request.GET.get('email')
user.mobile = request.GET.get('mobile')
user.save()
return HttpResponseRedirect('/auth/login')
示例4: login
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import username [as 别名]
def login():
password = request.form.get('inputPassword')
username = request.form.get('inputUsername')
user = User()
user.username = username
user.password = password
remember = False
if request.form.get('remember_me') == 'on':
remember = True
login_user(user, remember=remember)
rest = Rest()
user.other = rest.get('/auth/user')
# login_user(user, remember=remember)
if user.other.get('message'):
flash(user.other.get('message'), 'error')
logout_user()
return redirect(request.form.get('request_url'))