当前位置: 首页>>代码示例>>Python>>正文


Python MyRegistrationForm.is_valid方法代码示例

本文整理汇总了Python中forms.MyRegistrationForm.is_valid方法的典型用法代码示例。如果您正苦于以下问题:Python MyRegistrationForm.is_valid方法的具体用法?Python MyRegistrationForm.is_valid怎么用?Python MyRegistrationForm.is_valid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在forms.MyRegistrationForm的用法示例。


在下文中一共展示了MyRegistrationForm.is_valid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: register_user

# 需要导入模块: from forms import MyRegistrationForm [as 别名]
# 或者: from forms.MyRegistrationForm import is_valid [as 别名]
def register_user(request):
    if request.method == 'POST':
        form = MyRegistrationForm(request.POST)
        if form.is_valid():
            # if not (form.cleaned_data['user_type'] == 'Patient'):
            #    # if its a patient, we dont need to check his username
            #    response = java_insertUser(form)
            # else:
            if not (userExists(form.cleaned_data['username'])):
                # if the user does not exist
                return HttpResponseRedirect('/accounts/register_failed')
            # else save him
            response = java_insertStaff(form)

            if (response):
                form.save()
                return HttpResponseRedirect('/accounts/register_success')
            else:
                return HttpResponseRedirect('/accounts/register_failed')
    else:
        form = MyRegistrationForm()
    args = {}
    args.update(csrf(request))

    args['form'] = form

    return render(request, 'register.html', args)
开发者ID:KostasPapagiannopoulos,项目名称:hua_hospitalServices,代码行数:29,代码来源:views.py

示例2: reg

# 需要导入模块: from forms import MyRegistrationForm [as 别名]
# 或者: from forms.MyRegistrationForm import is_valid [as 别名]
def reg(request):
    
    if request.method =='POST':
        form = MyRegistrationForm(request.POST)
        if form.is_valid():
            form.save()
            username= request.POST.get('username','')
            email= request.POST.get('email','')
            subject = 'Hi {0} Welcome to Shabingo'.format(username)
            msg="Hi {0},".format(username)
            msg=msg+settings.WELCOME_EMAIL
            message = msg
           
            recipients = ['[email protected]']
            if email:
                recipients.append(email)            
           
            send_mail(subject, message, '[email protected]', recipients)
         
            return HttpResponseRedirect('thank-you')

    else:
        form = MyRegistrationForm()

    return render(request, 'reg.html', {'form': form})
开发者ID:maralad,项目名称:shabingo,代码行数:27,代码来源:views.py

示例3: register_user

# 需要导入模块: from forms import MyRegistrationForm [as 别名]
# 或者: from forms.MyRegistrationForm import is_valid [as 别名]
def register_user(request):
	# If the form has been submitted...
    if request.method == "POST":
    	# form = UserCreationForm(request.POST)
    	# we are going to pass the values of request.POST a dictionary to 
        # UserCreationForm and create a form object
    	# A form bound to the POST data
        form = MyRegistrationForm(request.POST)
        # if form is validated then the form object should be saved 
        # with the resgitration information of the new user 
        if form.is_valid():
            form.save()
            # now HttpResponseRedirect takes us to  url(r'^accounts/register_success/$','django_test.views.register_success')
            # now accounts/register_success/ causes the excution of django_test.views.register_success views
            return HttpResponseRedirect('/accounts/register_success')
    
    # for security purpose we have to embedd csrf tokens into agrs which will help us to know this post
    # method is coming from a reliable source 
        
    args={}
    args.update(csrf(request))
    # now we are embedding a blank user creation form into the args, it has no information put in it
    args['form'] = MyRegistrationForm()
    print args
    return render_to_response('register.html',args)
开发者ID:vaibhav-rbs,项目名称:article,代码行数:27,代码来源:views.py

示例4: register_user

# 需要导入模块: from forms import MyRegistrationForm [as 别名]
# 或者: from forms.MyRegistrationForm import is_valid [as 别名]
def register_user(request):
	if request.method == 'POST':
		registration_form = MyRegistrationForm(request.POST)
		#non-successful profile update
		#registration success
		if registration_form.is_valid():
			registration_form.save()
			send_mail('NEW USER SIGNUP', registration_form.cleaned_data['username'], '[email protected]', ['[email protected]'], fail_silently=False)

			if request.is_ajax():
				return HttpResponse('OK')
			else:
				return HttpResponseRedirect('/accounts/register_success')
		else:
			if request.is_ajax():
				errors_dict = {}
				for error in registration_form.errors:
					e = registration_form.errors[error]
					errors_dict[error] = unicode(e)

				return HttpResponseBadRequest(json.dumps(errors_dict))
	else:
		registration_form = MyRegistrationForm()

	args = {}
	args.update(csrf(request))

	args['form'] = registration_form;

	return render_to_response('register.html', args, context_instance=RequestContext(request))
开发者ID:CodeLegions,项目名称:cshub_site,代码行数:32,代码来源:views.py

示例5: home

# 需要导入模块: from forms import MyRegistrationForm [as 别名]
# 或者: from forms.MyRegistrationForm import is_valid [as 别名]
def home(request):
    mylogfunction()
    logger.debug("this is a debug message from home!")
    if request.method =='POST':
        form = MyRegistrationForm(request.POST)
        if form.is_valid():
            form.save()
            username= request.POST.get('username','')
            email= request.POST.get('email','')
            subject = 'Hi {0} Welcome to Shabingo'.format(username)
            msg="Hi {0},".format(username)

            #Email text stored in the settings.py file
            msg=msg+settings.WELCOME_EMAIL
            message = msg
        
            recipients = ['[email protected]']
            if email:
                recipients.append(email)            
           
            send_mail(subject, message, '[email protected]', recipients)
            
            
            #send_mail(subject, message, sender, recipients)
            messages.success(request, 'Thank you for joining!')
            return HttpResponseRedirect('thank-you')

    else:
        form = MyRegistrationForm()
        return render(request, 'signup.html', {'form': form})

    return render(request, 'signup.html', {'form': form})
开发者ID:maralad,项目名称:shabingo,代码行数:34,代码来源:views.py

示例6: edituser

# 需要导入模块: from forms import MyRegistrationForm [as 别名]
# 或者: from forms.MyRegistrationForm import is_valid [as 别名]
def edituser(request,user_name=1):
	username = user_name
	user = db.auth_user.find({'username':user_name},{"first_name":1,"last_name":1, "_id":0,"username":1,"email":1})
	if request.POST:
		form = MyRegistrationForm(request.POST)
		if form.is_valid():
			a = db.auth_user.update({'username':username},{'$set':{'username':form.data['username'],'first_name':form.data['first_name'],'last_name':form.data['last_name'],'email':form.data['email']}})
			return HttpResponseRedirect('/accounts/loggedin')
		else:
			a = db.auth_user.update({'username':username},{'$set':{'username':form.data['username'],'first_name':form.data['first_name'],'last_name':form.data['last_name'],'email':form.data['email']}})
			return HttpResponseRedirect('/accounts/loggedin')
		
	else:
		form = MyRegistrationForm()

	args = {}
	args.update(csrf(request))
	data = user	
	for info in data:
		form.fields["first_name"].initial = info['first_name']
		form.fields["last_name"].initial = info['last_name']
		form.fields["username"].initial = info['username']
		form.fields["email"].initial = info['email']
	args['form'] = form
	args['user'] = user_name
	return render_to_response('edit.html', args)
开发者ID:pavank812,项目名称:example,代码行数:28,代码来源:views.py

示例7: register_user

# 需要导入模块: from forms import MyRegistrationForm [as 别名]
# 或者: from forms.MyRegistrationForm import is_valid [as 别名]
def register_user(request):
	currentPath = request.POST.get('currentPath', '')
	currentPath = currentPath.replace("invalid/", "").replace("registered/", "")
	username=request.POST.get('email')
	password=request.POST.get('password1')
	if request.method == 'POST':
		form = MyRegistrationForm(request.POST)
		if form.is_valid():
			form.save()
			user = auth.authenticate(username=username, password=password)

			if user is not None:
				auth.login(request, user)
			if "log" in currentPath:
				return HttpResponseRedirect(currentPath)
			else:
				return HttpResponseRedirect('/register_success')
		elif "log" in currentPath:
			return HttpResponseRedirect(currentPath + "registered")
	else:
		form = MyRegistrationForm()
		form.fields['password1'].label = "密码"
		form.fields['password2'].label = "再次输入密码"
	args = {}
	args.update(csrf(request))
	
	args['form'] = form
	
	return render_to_response('register.html', args)
开发者ID:seungjulee,项目名称:theForce,代码行数:31,代码来源:views.py

示例8: register_user

# 需要导入模块: from forms import MyRegistrationForm [as 别名]
# 或者: from forms.MyRegistrationForm import is_valid [as 别名]
def register_user(request):
    if request.method == 'POST':
        form = MyRegistrationForm(request.POST)
        if form.is_valid():
            # autologin after register here
            new_user = form.save()
            new_user = authenticate(username=request.POST['username'],
                                        password=request.POST['password1'])
            auth.login(request, new_user)
            userprofile = UserProfile(name=request.POST['username'])
            userprofile.save()
            return HttpResponseRedirect('/accounts/loggedin')
        else:
            args = {}
            args.update(csrf(request))
    
            args['form'] = MyRegistrationForm()
            context={"invalid": True,"args":args}
            return render(request, 'register.html', context)

    args = {}
    args.update(csrf(request))
    
    args['form'] = MyRegistrationForm()
    context={"invalid": False,"args":args}
   
    return render(request, "register.html", context)
开发者ID:ryanwongsa,项目名称:CareerStudyAdvisor,代码行数:29,代码来源:views.py

示例9: manage_account

# 需要导入模块: from forms import MyRegistrationForm [as 别名]
# 或者: from forms.MyRegistrationForm import is_valid [as 别名]
def manage_account(request,user_id):
	a = User.objects.get(pk=user_id)
	print a
	print request.user.username
	if request.method == "POST":
		print "test1"
		form = MyRegistrationForm(request.POST, instance = a)
		print "test2"
		#print form.is_valid()
		try:
			if form.is_valid():
				form.save()
				print "test2"
				a.is_active = True
				a.save()
				messages.warning(request,'Updated successfully')
				return HttpResponseRedirect(reverse('polls:index'))
		except:
			return render(request, 'polls/manage_account.html', {
			    'form':form,
			    'user_id':a.id,
		    })
	else:
		form = MyRegistrationForm()
	c = {}
	c.update(csrf(request))
	c.update({'user_id':a.id})
	c.update({'form':form})
	c.update({'username':a.username})
	c.update({'email':a.email})
	c.update({'first_name':a.first_name})
	c.update({'last_name':a.last_name})
	return render_to_response('polls/manage_account.html',c)
开发者ID:manikanta-kumar-allakki,项目名称:polls-india,代码行数:35,代码来源:views.py

示例10: reg_view

# 需要导入模块: from forms import MyRegistrationForm [as 别名]
# 或者: from forms.MyRegistrationForm import is_valid [as 别名]
def reg_view(request):
  if request.method == 'POST':
    form = MyRegistrationForm(request.POST)
    if form.is_valid() and len(request.POST.get('zipcode')) == 5:
      form.save()
      return HttpResponseRedirect('/loggedin')
    else:
      return HttpResponseRedirect('/invalid')
开发者ID:mihirkelkar,项目名称:Stackr,代码行数:10,代码来源:views.py

示例11: register_user

# 需要导入模块: from forms import MyRegistrationForm [as 别名]
# 或者: from forms.MyRegistrationForm import is_valid [as 别名]
def register_user(request,context):
	context.update(csrf(request))
	if request.method =="POST":	
		form = MyRegistrationForm(request.POST)
		if form.is_valid():
			form.save()
			return render_to_response('frontEnd/djangoBlog/register_success.html',context) #no need to create a new url like register_success just render that html is enough (url is /accounts/register)
	context['form'] = MyRegistrationForm()
	return render_to_response('frontEnd/djangoBlog/register.html',context)
开发者ID:hadi2f244,项目名称:djangoProject,代码行数:11,代码来源:views.py

示例12: register_user

# 需要导入模块: from forms import MyRegistrationForm [as 别名]
# 或者: from forms.MyRegistrationForm import is_valid [as 别名]
def register_user(request):
    if request.method == 'POST':

        form = MyRegistrationForm(request.POST)
        if form.is_valid():
            new_user = form.save()
            return HttpResponseRedirect("/accounts/login")
    else:
        form = MyRegistrationForm()
    return render(request, "ckmg/signup.html", {'form': form,})
开发者ID:Shiv-Dangi,项目名称:ck_management,代码行数:12,代码来源:views.py

示例13: register_user

# 需要导入模块: from forms import MyRegistrationForm [as 别名]
# 或者: from forms.MyRegistrationForm import is_valid [as 别名]
def register_user(request):
    if request.method == 'POST':
        form = MyRegistrationForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/accounts/register_success')
    c = {}
    c.update(csrf(request))
    c['form'] = MyRegistrationForm()
    return render_to_response('register.html', c)
开发者ID:kuldeeprishi,项目名称:articles,代码行数:12,代码来源:views.py

示例14: register

# 需要导入模块: from forms import MyRegistrationForm [as 别名]
# 或者: from forms.MyRegistrationForm import is_valid [as 别名]
def register(request):
    if request.method == 'POST':
        form = MyRegistrationForm(request.POST)
        if form.is_valid():
            form.save()
            return render(request, 'index.html', {})

    args = {}
    args.update(csrf(request))
    args['form'] = MyRegistrationForm()
    return render_to_response('login.html', args)
开发者ID:spoiledPiggy,项目名称:myblog,代码行数:13,代码来源:views.py

示例15: register

# 需要导入模块: from forms import MyRegistrationForm [as 别名]
# 或者: from forms.MyRegistrationForm import is_valid [as 别名]
def register(request):
	if request.user.is_authenticated():
		return HttpResponseRedirect('/')
	else:
		args = {}
		args['register_active'] = True
		if request.GET.get('inv'):
			args['invite'] = request.GET.get('inv')

		if request.method == 'POST':
			form = MyRegistrationForm(request.POST)
			args['form'] = form
			if form.is_valid():
				# Pick data
				invite = request.POST.get('invite')
				initial_balance = int(request.POST.get('balance'))

				# Save user with Default properties
				form.save()

				# Pick the user
				user = User.objects.get(username=form.get_username())

				# Custom USER data
				uinfo = UserProfile()
				uinfo.user = user

				# BALANCE
				if initial_balance > 50:
					initial_balance = initial_balance + (initial_balance * 0.10)

				# Check invite
				if invite:
					try:
						host_user = UserProfile.objects.get(invite_id=invite)
					except UserProfile.DoesNotExist:
						host_user = None

					if host_user:
						initial_balance = initial_balance + 10

				# SAVE USER CUSTOM DATA
				uinfo.initial_balance = initial_balance
				uinfo.invite_id = get_random_string(length=30)
				uinfo.save()
				return HttpResponseRedirect('/accounts/register_success')
			args['register_active'] = True
			return render(request, 'register.html', args)

		else:
			args['form'] = MyRegistrationForm()
			
			args.update(csrf(request))
			return render_to_response('register.html', args)
开发者ID:deniswvieira,项目名称:FMQBetApp,代码行数:56,代码来源:views.py


注:本文中的forms.MyRegistrationForm.is_valid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。