本文整理汇总了Python中forms.MyRegistrationForm.setName方法的典型用法代码示例。如果您正苦于以下问题:Python MyRegistrationForm.setName方法的具体用法?Python MyRegistrationForm.setName怎么用?Python MyRegistrationForm.setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms.MyRegistrationForm
的用法示例。
在下文中一共展示了MyRegistrationForm.setName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register_user
# 需要导入模块: from forms import MyRegistrationForm [as 别名]
# 或者: from forms.MyRegistrationForm import setName [as 别名]
def register_user(request):
if request.method == 'POST':
form = MyRegistrationForm(request.POST)
handle = open('/home/rishabh/hospital/counter.txt', 'r+')
count = int(handle.read())
handle.close()
if form.is_valid():
temp = request.POST.get('username','')
form.setID('s'+str(count+1))
trans = 's'+str(count+1)
form.setName(temp)
handle1 = open('/home/rishabh/hospital/counter.txt', 'w')
handle1.write(str(count+1))
handle1.close()
form.save()
registerID = User.objects.get( username = 's'+str(count+1))
return HttpResponseRedirect('/accounts/register_success/%s/' % registerID.id)
args={}
args.update(csrf(request))
args['form']=MyRegistrationForm()
return render_to_response('register.html', args)
示例2: register_user
# 需要导入模块: from forms import MyRegistrationForm [as 别名]
# 或者: from forms.MyRegistrationForm import setName [as 别名]
def register_user(request):
if request.method == 'POST':
form = MyRegistrationForm(request.POST)
handle = open('/home/rishabh/hospital/counter.txt', 'r+')
count = int(handle.read())
handle.close()
if form.is_valid():
temp = request.POST.get('username','')
form.setID('s'+str(count+1))
trans = 's'+str(count+1)
form.setName(temp)
handle1 = open('/home/rishabh/hospital/counter.txt', 'w')
handle1.write(str(count+1))
handle1.close()
print "SUCCESS"
form.save()
return render_to_response('register_success.html', {'username':trans})
args={}
args.update(csrf(request))
args['form']=MyRegistrationForm()
return render_to_response('register.html', args)