本文整理汇总了Python中models.Account.username方法的典型用法代码示例。如果您正苦于以下问题:Python Account.username方法的具体用法?Python Account.username怎么用?Python Account.username使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Account
的用法示例。
在下文中一共展示了Account.username方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import username [as 别名]
def create(request):
if request.method == 'POST':
# save new account
name = request.POST['name']
username = request.POST['username']
password = request.POST['password']
email = request.POST['email']
account = Account()
account.name = name
account.username = username
account.password = password
account.email = email
account.perfil = 'N'
account.save()
return HttpResponseRedirect(reverse('account-login'))
return render_to_response('account/account_create.html',{'request':request},
context_instance=RequestContext(request))
示例2: addUser
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import username [as 别名]
def addUser(request):
'''
takes in user information and adds it to the database
upload images as files in your post request
:param request:
:return: nothing
'''
username = request.POST.get('username', '')
password = request.POST.get('password', '')
user = Account()
user.first_name = request.POST.get('first_name', '')
user.last_name = request.POST.get('last_name', '')
user.email = request.POST.get('email', '')
user.username = username
user.about_me = request.POST.get('about_me', '')
user.password = password
user.profile_image = request.FILES.get('profile')
user.cover_image = request.FILES.get('cover')
#create user secret key
m = hashlib.md5()
user.friends = json.dumps(request.POST.get('friends', [])) #list of usernames
user.history = json.dumps(request.POST.get('history', [])) #list of civi's visited
user.awards = json.dumps(request.POST.get('awards', [])) #list of user awards
m.update("{username}{password}{int}".format(username=user.username, password=password, int=random.randint(0, sys.maxint)))
secret_key = m.hexdigest()
user.secret_key= secret_key
user.save()
try:
user.save()
except Exception as e:
return JsonResponse({'result': e})
return JsonResponse({'status': 200, 'result': user.secret_key})