本文整理汇总了Python中rango.forms.UserForm类的典型用法代码示例。如果您正苦于以下问题:Python UserForm类的具体用法?Python UserForm怎么用?Python UserForm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UserForm类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: register
def register(request):
# get context as always
context = RequestContext(request)
cat_lsit = get_category_list()
# boolean to determine if registraton was succesful
registered = False
# if its HTTP POST then processing form data
if request.method == 'POST':
# try and grab info from raw form
user_form = UserForm(data = request.POST)
profile_form = UserProfileForm(data = request.POST)
# if forms are valid
if user_form.is_valid() and profile_form.is_valid():
# save the form to database
user = user_form.save()
# hash the password to set password method
user.set_password(user.password)
user.save()
# sort user profile instance, set as false to avoid integrity problems
profile = profile_form.save(commit = False)
profile.user = user
# update registration boolean now registration is finished
registered = True
#invalid form so print error
else:
print( user_form.errors, profile_form.errors)
else:
user_form = UserForm()
profile_form = UserProfileForm()
# reder template
context_dict = {'user_form': user_form, 'profile_form': profile_form, 'registered': registered, 'cat_list': cat_list}
return render_to_response('rango/register.html', context_dict, context)
开发者ID:euranium,项目名称:tango,代码行数:32,代码来源:views.py
示例2: register
def register(request):
registered = False
if request.method == 'POST':
user_form = UserForm(data=request.POST)
profile_form = UserProfileForm(data=request.POST)
if user_form.is_valid() and profile_form.is_valid():
user = user_form.save()
user.set_password(user.password) # hashes password
user.save()
profile = profile_form.save(commit=False)
profile.user = user
if 'picture' in request.FILES:
profile.picture = request.FILES['picture']
profile.save()
registered = True
else:
print user_form.errors, profile_form.errors
else:
user_form = UserForm()
profile_form = UserProfileForm()
return render(request,
'rango/register.html',
{'user_form': user_form, 'profile_form': profile_form, 'registered': registered} )
开发者ID:phtan,项目名称:django-rango,代码行数:32,代码来源:views.py
示例3: register
def register(request):
registered = False
if request.method == 'POST':
user_form = UserForm(data=request.POST)
profile_form = UserProfileForm(data=request.POST)
# If the two forms are valid
if user_form.is_valid() and profile_form.is_valid():
user = user_form.save()
user.set_password(user.password) # Hash the password
user.save() # Save the password
profile = profile_form.save(commit=False)
profile.user = user
# Check if user provides a profile picture
if 'picture' in request.FILES:
profile.picture = request.FILES['picture']
profile.save()
registered = True
else:
print user_form.errors, profile_form.errors
# If this is not a HTTP POST, then render the forms for input
else:
user_form = UserForm()
profile_form = UserProfileForm()
return render(request, 'rango/register.html',
{'user_form': user_form, 'profile_form': profile_form, 'registered': registered})
开发者ID:jonsuth,项目名称:tangowithdjango,代码行数:35,代码来源:views.py
示例4: register
def register(request):
registered = False
## Testing cookies
if request.session.test_cookie_worked():
print ">>>>> Test cookie worked!"
# request.session.delete_test_cookie()
## Testing cookies
if request.method == 'POST':
user_form = UserForm(data=request.POST)
profile_form = UserProfileForm(data=request.POST)
if user_form.is_valid() and profile_form.is_valid():
user = user_form.save()
user.set_password(user.password)
user.save()
profile = profile_form.save(commit = False)
profile.user = user
if 'picture' in request.FILES:
profile.picture = request.FILES['picture']
profile.save()
registered = True
else:
print user_form.errors, profile_form.errors
else:
user_form = UserForm()
profile_form = UserProfileForm()
return render(request, 'rango/register.html', {'user_form':user_form, 'profile_form':profile_form, 'registered': registered, 'cat_list':cat_list, })
开发者ID:nishant57,项目名称:rango,代码行数:35,代码来源:views.py
示例5: register
def register(request):
registered = False
if request.method == "POST":
user_form = UserForm(data=request.POST)
profile_form = UserProfileForm(data=request.POST)
if user_form.is_valid() and profile_form.is_valid():
user = user_form.save()
user.set_password(user.password)
user.save()
profile = profile_form.save(commit=False)
profile.user = user
if "picture" in request.FILES:
profile.picture = request.FILES["picture"]
profile.save()
registered = True
else:
print user_form.errors, profile_form.errors
else:
user_form = UserForm()
profile_form = UserProfileForm()
return render(
request, "rango/register.html", {"user_form": user_form, "profile_form": profile_form, "registered": registered}
)
开发者ID:astelmach,项目名称:Rango,代码行数:26,代码来源:views.py
示例6: register
def register(request):
if request.session.test_cookie_worked():
print 'Test cookie worked'
request.session.delete_test_cookie()
context = RequestContext(request)
registered = False
if request.method == 'POST':
user_form = UserForm(data=request.POST)
profile_form = UserProfileForm(data=request.POST)
if user_form.is_valid() and profile_form.is_valid():
user = user_form.save()
user.set_password(user.password)
user.save()
profile = profile_form.save(commit=False)
profile.user = user
if 'picture' in request.FILES:
profile.picture = request.FILES['picture']
profile.save()
registered = True
else:
print user_form.errors, profile_form.errors
else:
user_form = UserForm()
profile_form = UserProfileForm()
context_dict = {'user_form' : user_form, 'profile_form': profile_form, 'registered':registered}
return render_to_response('rango/register.html', context_dict, context)
开发者ID:scientist1642,项目名称:cyrus,代码行数:35,代码来源:views.py
示例7: register
def register(request):
context = RequestContext(request)
context_dict = {'cat_list': get_category_list()}
registered = False
if request.method == 'POST':
user_form = UserForm(data=request.POST)
profile_form = UserProfileForm(data=request.POST)
if user_form.is_valid() and profile_form.is_valid():
user = user_form.save()
user.set_password(user.password)
user.save()
profile = profile_form.save(commit=False)
profile.user = user
if 'picture' in request.FILES:
profile.picure = request.FILES['picture']
profile.save()
registered = True
else:
context_dict['errors'] = user_form.errors + profile_form.errors
else:
user_form = UserForm()
profile_form = UserProfileForm()
context_dict['user_form'] = user_form
context_dict['profile_form'] = profile_form
context_dict['registered'] = registered
return render_to_response('rango/register.html', context_dict, context)
开发者ID:VijayAmbekar,项目名称:tango_project,代码行数:29,代码来源:views.py
示例8: register
def register(request):
registered = False
if request.method == 'POST':
user_form = UserForm(data=request.POST)
profile_form = UserProfileForm(data = request.POST)
if user_form.is_valid() and profile_form.is_valid():
user = user_form.save()
user.set_password(user.password)
user.save()
profile = profile_form.save(commit = False)
profile.user = user
if 'picture' in request.FILES:
profile.picture = request.FILES['picture']
profile.save()
registered = True
else:
print user_form.errors, profile_form.errors
else:
user_form=UserForm()
profile_form = UserProfileForm()
context_dict = {'user_form': user_form, 'profile_form':profile_form, 'registered':registered}
bar_list = Bar.objects.order_by('-numero_visitas')
context_dict['bares'] = bar_list
return render(request, 'rango/register.html', context_dict)
开发者ID:lorenmanu,项目名称:DAI,代码行数:30,代码来源:views.py
示例9: register
def register(request):
context = RequestContext(request)
registered = False
if request.session.test_cookie_worked():
print ">>>>>TEST COOKIE WORKED"
request.session.delete_test_cookie()
if request.POST:
form = UserForm(request.POST)
profile_form = UserProfileForm(request.POST)
if form.is_valid() and profile_form.is_valid():
user = form.save()
user.set_password(user.password)
user.save()
profile = profile_form.save(commit=False)
profile.user = user
profile.picture = request.FILES['picture']
profile.save()
registered = True
else:
form.errors, profile_form.errors
else:
form = UserForm()
profile_form = UserProfileForm()
return render_to_response('rango/register.html',{'form':form,'profile_form':profile_form,'registered':registered},context)
开发者ID:simonmh2u,项目名称:DjangoLearning,代码行数:30,代码来源:views.py
示例10: register
def register(request):
context = RequestContext(request)
registered = False #Set to False initially. Code changes value to True when registration succeeds.
if request.method == 'POST':
user_form = UserForm(data=request.POST)
profile_form = UserProfilForm(data=request.POST)
if user_form.is_valid() and profile_form.is_valid():
user = user_form.save()
user.set_password(user.password) # Hash the password with the set_password method.
user.save()
profile = profile_form.save(commit=False)
profile.user = user
if 'picture' in request.FILES:
profile.picture = request.FILES['picture']
profile.save()
registered = True
else:
print user_form.errors, profile_form.errors
else:
user_form = UserForm()
profile_form = UserProfilForm()
return render_to_response(
'rango/register.html',
{'user_form': user_form, 'profile_form': profile_form, 'registered': registered},
context)
开发者ID:sH-i-Zz,项目名称:Rango,代码行数:33,代码来源:views.py
示例11: register
def register(request):
if request.session.test_cookie_worked():
print ">>>>Test cookie worked !!!"
request.session.delete_test_cookie()
registered = False
if request.method == "POST":
user_form = UserForm(data = request.POST)
profile_form = UserProfileForm(data = request.POST)
if user_form.is_valid() and profile_form.is_valid():
user = user_form.save()
user.set_password(user.password)
user.save()
print "Part 1 done"
profile = profile_form.save(commit = False)
profile.user = user
print "Part 1.5 done"
if 'pic' in request.FILES:
profile.pic = request.FILES['pic']
profile.save()
print "Part 2 done"
registered = True
else:
print user_form.errors, profile_form.errors
else:
print "Part 3 executing"
user_form = UserForm()
profile_form = UserProfileForm()
print "registered = ",registered
return render(request,
'rango/register.html',
{'user_form': user_form, 'profile_form':profile_form, 'registered': registered })
开发者ID:hmishra2250,项目名称:rango,代码行数:32,代码来源:views.py
示例12: register
def register(request):
#if request.session.test_cookie_worked():
# print ">>> TEST COOKIE WORKED..."
# request.session.delete_test_cookie()
context = RequestContext(request)
registered = False
if request.method =='POST':
user_form = UserForm(data=request.POST) #gets the information entered into the form
profile_form = UserProfileForm(data=request.POST)
if user_form.is_valid() and profile_form.is_valid():
user = user_form.save()
user.set_password(user.password)
user.save()
profile = profile_form.save(commit=False)
profile.user = user
if 'picture' in request.FILES:
profile.picture = request.FILES['picture']
profile.save()
registered = True
else:
print user_form.errors, profile_form.errors
else:
user_form = UserForm()
profile_form = UserProfileForm()
return render_to_response(
'rango/register.html',
{'user_form': user_form, 'profile_form': profile_form, 'registered': registered},
context)
开发者ID:shrikant-git,项目名称:Django-Project,代码行数:35,代码来源:views.py
示例13: register
def register(request):
registered = False
if request.method == 'POST':
user_form = UserForm(data=request.POST)
profile_form = UserProfileForm(data=request.POST)
if user_form.is_valid() and profile_form.is_valid():
# save user's form data to the db
user = user_form.save()
# Hash the PASSWORD
user.set_password(user.password)
user.save()
profile = profile_form.save(commit=False)
profile.user = user
# Did the user provide a profile picture?
if 'picture' in request.FILES:
profile.picture = request.FILES['picture']
profile.save()
registered = True
else:
print(user_form.errors, profile_form.errors)
# not POST HTTP
else:
user_form = UserForm()
profile_form = UserProfileForm()
return render(request,
'rango/register.html',
{'user_form': user_form,
'profile_form': profile_form,
'registered': registered})
开发者ID:GriMel,项目名称:TwDTutor,代码行数:34,代码来源:views.py
示例14: register
def register(request):
# Value if the registration was successful. Changes in the end of the process
registered = False
if request.method = 'POST':
user_form = UserForm(data=request.POST)
profile_form = UserProfileForm(data=request.POST)
if user_form.is_valid() and profile_form.is_valid():
user = user_form.save()
user.set_password(user.password)
user.save()
# Use commit to delay to avoid integrity problems.
profile = profile_form.save(commit=False)
profile.user = user
if 'picture' in request.FILES:
profile.picture = request.FILES['picture']
# Now saving profile.
profile.save()
registered = True
else:
print user_form.errors, profile_form.errors
# Render the template depending on the context
return render(request, 'rango/register.html', {'user_form': user_form, 'profile_form': profile_form, 'registered': registered} )
开发者ID:glebmak,项目名称:tango_with_django_project,代码行数:28,代码来源:views.py
示例15: register
def register(request):
# A boolean value for telling the template
# whether the registration was successful
# Set to False initially. Code changes value to
# True when registration succeeds
registered = False
# If it's a HTTP POST, we're interested in processing form data
if request.method == 'POST':
# Attempt to grab information from the faw form information
# Note that we make use of both UserForm and UserProfileForm
user_form = UserForm(data=request.POST)
profile_form = UserProfileForm(data=request.POST)
# If the two forms are valid..
if user_form.is_valid() and profile_form.is_valid():
#Save the user's form data to the database
user = user_form.save()
# Now we hash the password with the set_password method
# Once hashed, we can update the user object.
user.set_password(user.password)
user.save()
# Now sort out the UserProfile instance
# Since we need to set the user attribute ourselves,
# we set commit=False. This delays saving the model
# Until we're ready to avoid integrity problems
profile = profile_form.save(commit=False)
profile.user = user
# Did the user provide a profile picture?
# if so we need to get it from the input form and
# put it in the UserProfile model.
if 'picture' in request.FILES:
profile.picture = request.FILES['picture']
# Now we save the UserProfile model instane
profile.save()
# Update our variable to indicate that the template
# registartion was successful
registered = True
else:
# Invalid form or forms - mistakes or something else
# Print problems to the terminal.
print(user_form.errors, profile_form.errors)
else:
# Not a HTTP POST, so we render our form using two ModelForm instances
# These forms will be blank, ready for user input
user_form = UserForm()
profile_form = UserProfileForm()
# Render the template depending on the context
return render(request,'rango/register.html',
{'user_form': user_form,
'profile_form': profile_form,
'registered': registered})
开发者ID:2312420,项目名称:tango_with_django_project,代码行数:60,代码来源:views.py
示例16: register
def register(request):
#Like before, get the request's context
context = RequestContext(request)
cat_list = get_category_list()
# A boolean value for telling the template whether the registration was successful
# Set to False initiall. Code changes value to True when registration succeeds
registered = False
# If it's a HTTP POST, we're interested in processing form data.
if request.method == 'POST':
# Attempt to grab information from the raw form information
# Note that we make use of both UserForm and UserProfileForm
user_form = UserForm(data=request.POST)
profile_form = UserProfileForm(data=request.POST)
# If the two forms are valid...
if user_form.is_valid() and profile_form.is_valid():
# Save the user's form data to the database.
user = user_form.save()
# Now we hash the password with the set_password method.
# Once hashed, we can update the user object.
user.set_password(user.password)
user.save()
# Now sort out the UserProfile instance
# Since we need to set the user attribute ourselves, we set commit=False
# This delays saving the model until we're ready to avoid integrity problems
profile = profile_form.save(commit=False)
profile.user = user
# Did the user provide a profile picture?
# If so, we need to get it from the input form and put it in the UserProfile model
if 'picture' in request.FILES:
profile.picture - request.FILES['picture']
# Now we save the UserProfile model instance
profile.save()
# Update our variable to tell the template registration was successful
registered = True
# Invalid form or forms - mistakes or somethign else?
# Print problems to the terminal
# They'll also be shown to the user
else:
print user_form.errors, profile_form.errors
# Not a HTTP POST, so we render our form using to ModelForm instances
# These forms will be blank, ready for user input
else:
user_form = UserForm()
profile_form = UserProfileForm()
context_dict = {'user_form': user_form, 'profile_form': profile_form,
'registered': registered, 'cat_list': cat_list}
# Render the template depending on the context
return render_to_response('rango/register.html', context_dict, context)
开发者ID:bugzPDX,项目名称:rango,代码行数:60,代码来源:views.py
示例17: register
def register(request):
context = RequestContext(request)
registered = False
if request.method == 'POST':
user_form = UserForm(data=request.POST)
profile_form = UserProfileForm(data=request.POST)
calc_form = CalcForm(data=request.POST)
if user_form.is_valid() and profile_form.is_valid() and calc_form.is_valid():
user = user_form.save()
user.set_password(user.password)
user.save()
profile = profile_form.save(commit=False)
profile.user = user
profile.save()
calc = calc_form.save(commit=False)
calc.user = user
calc.gender = profile.gender
calc.height_for_calc = profile.height
calc.weight_for_calc = profile.weight
calc.save()
registered = True
else:
print(user_form.errors, profile_form.errors)
else:
user_form = UserForm()
profile_form = UserProfileForm()
calc_form = CalcForm()
return render_to_response('rango/register.html',{'user_form': user_form, 'profile_form': profile_form, 'calc_form': calc_form, 'registered' : registered}, context)
开发者ID:capstoneprojectgymmie,项目名称:gymmie-test,代码行数:28,代码来源:views.py
示例18: register
def register(request):
# boolean for telling the template whether registration is successful
if request.session.test_cookie_worked():
print ">>>> TEST COOKIE WORKED!"
request.session.delete_test_cookie()
register = False
if request.method == 'POST':
user_form = UserForm(data=request.POST)
profile_form = UserProfileForm(data=request.POST)
if user_form.is_valid() and profile_form.is_valid():
user = user_form.save()
user.set_password(user.password)
user.save()
profile = profile_form.save(commit=False)
profile.user = user
if 'picture' in request.FILES:
profile.picture = request.FILES['picture']
profile.save()
register = True
else:
print user_form.errors, profile_form.errors
else:
user_form = UserForm()
profile_form = UserProfileForm()
return render(request, 'rango/register.html',
{'user_form': user_form, 'profile_form': profile_form, 'register': register})
开发者ID:z23han,项目名称:tango-django,代码行数:33,代码来源:views.py
示例19: register
def register(request):
if request.session.test_cookie_worked():
print ">>>Test cookie worked!"
request.session.delete_test_cookie()
context = RequestContext(request)
categories = get_category_list()
registered = False
if request.method == 'POST':
user_form = UserForm(data=request.POST)
profile_form = UserProfileForm(data=request.POST)
if user_form.is_valid() and profile_form.is_valid():
user = user_form.save()
user.set_password(user.password)
user.save()
profile = profile_form.save(commit=False)
profile.user = user
if 'picture' in request.FILES:
profile.picture = request.FILES['picture']
profile.save()
registered = True
else:
print user_form.errors, profile_form.errors
else:
user_form = UserForm()
profile_form = UserProfileForm()
return render_to_response('rango/register.html',
dict(user_form=user_form, profile_form=profile_form, registered=registered,
categories=categories),
context)
开发者ID:salmanwahed,项目名称:tango-with-django,代码行数:35,代码来源:views.py
示例20: register
def register(request):
# A boolean value for telling the template whether the registration was successful.
# Set to False initially. Code changes value to True when registration succeeds.
registered = False
if request.method == 'POST':
user_form = UserForm(data=request.POST)
profile_form = UserProfileForm(data=request.POST)
if user_form.is_valid() and profile_form.is_valid():
user = user_form.save()
user.set_password(user.password)
user.save()
profile = profile_form.save(commit=False)
profile.user = user
if 'picture' in request.FILES:
profile.picture = request.FILES['picture']
profile.save()
registered = True
else:
print(user_form.errors, profile_form.errors)
else:
user_form = UserForm()
profile_form = UserProfileForm()
return render(request, 'rango/register.html',
{'user_form': user_form, 'profile_form': profile_form, 'registered': registered})
开发者ID:erichideki,项目名称:tango-with-django,代码行数:33,代码来源:views.py
注:本文中的rango.forms.UserForm类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论