本文整理汇总了Python中models.UserInfo.save方法的典型用法代码示例。如果您正苦于以下问题:Python UserInfo.save方法的具体用法?Python UserInfo.save怎么用?Python UserInfo.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.UserInfo
的用法示例。
在下文中一共展示了UserInfo.save方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loginView
# 需要导入模块: from models import UserInfo [as 别名]
# 或者: from models.UserInfo import save [as 别名]
def loginView(request):
context = get_context(request)
# Forget AccountAccesses to merge if user goes somewhere then back to login.
if 'merge_access' in request.session:
del request.session['merge_access']
if 'merge_access_info' in request.session:
del request.session['merge_access_info']
if request.user.is_authenticated():
try:
access = request.user.accountaccess_set.all()[0]
except IndexError:
access = None
else:
client = access.api_client
user_info = client.get_profile_info(raw_token=access.access_token)
context['info'] = user_info
user = request.user
try:
user_profile = UserProfile.objects.get(user=user)
except UserProfile.DoesNotExist:
new_user_info = UserInfo()
new_user_info.save()
user_profile, just_created = UserProfile.objects.get_or_create(user=user, user_info=new_user_info)
# I'm not sure if this condition is necessary.
if just_created:
standarize_user_info(user_info)
if 'gender' in user_info:
user_profile.gender = user_info['gender']
user.save()
user_profile.save()
return render(request, 'login.html', context)
示例2: register
# 需要导入模块: from models import UserInfo [as 别名]
# 或者: from models.UserInfo import save [as 别名]
def register(request):
if request.method == 'POST': # If the form has been submitted...
row = UserInfo(email_id = request.POST['email'], password = request.POST['pwd'],
full_name = request.POST['fullname'])
row.save()
email = request.POST['email'];
return HttpResponseRedirect('alternative')
示例3: test_signals
# 需要导入模块: from models import UserInfo [as 别名]
# 或者: from models.UserInfo import save [as 别名]
def test_signals(self):
old_count = LogEntry.objects.count()
userobject = UserInfo(name='testname', \
surname='testsurname', \
birthday='2010-02-17', \
about='test', \
contacts='test');
userobject.save()
self.assertNotEqual(old_count, LogEntry.objects.count())
示例4: register
# 需要导入模块: from models import UserInfo [as 别名]
# 或者: from models.UserInfo import save [as 别名]
def register():
confirm = request.form['confirm']
email = request.form['email']
userID = request.form['hiddenfield']
password = request.form['hiddenfield2']
print userID," ",password
if password == confirm:
hashedPassword = generate_password_hash(password)
user = UserInfo(userID= userID,email= email,password= hashedPassword)
try:
user.save()
if login_user(user):
return redirect(url_for('GetList'))
else:
error="Unable to Log you in due to inactive account"
except Exception,e:
print str(e)
error="UserId taken. Please try another."
示例5: adduser
# 需要导入模块: from models import UserInfo [as 别名]
# 或者: from models.UserInfo import save [as 别名]
def adduser(request):
posData = request.POST
uid = posData.get('uid')
username = posData.get('username')
name = posData.get('name')
gender = posData.get('gender')
email = posData.get('email')
if gender == 'null':
gender = None
elif int(gender) == 0:
gender = 0
else:
gender = 1
if username and name and email:
if uid:
UserInfo.objects.filter(uid=int(uid)).update(username=username, realName=name, gender=gender, email=email)
else:
userInfo = UserInfo(username=username, realName=name, gender=gender, email=email)
userInfo.save()
return HttpResponseRedirect('/userlist/')
示例6: create_user_info
# 需要导入模块: from models import UserInfo [as 别名]
# 或者: from models.UserInfo import save [as 别名]
def create_user_info(*args, **kwargs):
if kwargs['created']:
user = kwargs['instance']
user_info = UserInfo(user=user)
user_info.save()
示例7: add_entry_user_info
# 需要导入模块: from models import UserInfo [as 别名]
# 或者: from models.UserInfo import save [as 别名]
def add_entry_user_info(user,
date):
new_user = UserInfo(username=user, last_agreement=date, enabled=True)
new_user.save()