本文整理汇总了Python中forms.MyRegistrationForm类的典型用法代码示例。如果您正苦于以下问题:Python MyRegistrationForm类的具体用法?Python MyRegistrationForm怎么用?Python MyRegistrationForm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MyRegistrationForm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reg
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})
示例2: register_user
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)
示例3: edituser
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)
示例4: register_user
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))
示例5: manage_account
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)
示例6: register_user
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)
示例7: register_user
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)
示例8: register_user
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)
示例9: home
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})
示例10: reg_view
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')
示例11: register_user
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)
示例12: register_user
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)
示例13: register_user
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,})
示例14: register_user
def register_user(request):
if request.method == 'POST':
form = MyRegistrationForm(request.POST)
if form.is_valid:
form.save()
return HttpResponseRedirect('/accounts/register_success')
args = {}
#args.update(csrf(request))
args['form'] = MyRegistrationForm()
return render(request,'register.html', args)
示例15: register
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)