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


Python forms.UserProfileForm类代码示例

本文整理汇总了Python中rango.forms.UserProfileForm的典型用法代码示例。如果您正苦于以下问题:Python UserProfileForm类的具体用法?Python UserProfileForm怎么用?Python UserProfileForm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: 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

示例2: 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)

        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:
        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:Ramesh7128,项目名称:tango-with-django,代码行数:28,代码来源:views.py

示例3: register

def register(request):
    context = RequestContext(request)

    registered = False

    # Post request
    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() # does this really save form data to the database?

            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
    # not a HTTP POST
    else:
        user_form = UserForm()
        profile_form = UserProfileForm()

    # render template 
    return render_to_response('rango/register.html', {'user_form': user_form, 
        'profile_form': profile_form, 'registered': registered, 'cat_list': get_category_list()}, context)
开发者ID:jonathan-s,项目名称:Rango,代码行数:34,代码来源:views.py

示例4: register

def register(request):

    if request.session.test_cookie_worked():
        print ">>>> TEST COOKIE WORKED!"
        request.session.delete_test_cookie()

    # 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 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 something 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 two ModelForm instances.
    # These forms will be blank, ready for user input.
    else:
        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:almok,项目名称:tangowithdjango,代码行数:60,代码来源:views.py

示例5: registration_register

def registration_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()
            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:ashvinikumar,项目名称:tango_with_django_project,代码行数:34,代码来源:views.py

示例6: register_profile

def register_profile(request):
    if request.user.is_authenticated():
        user = request.user
        registered = False
    
        if request.method == 'POST':
            profile_form = UserProfileForm(request.POST)

            if profile_form.is_valid():
                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 profile_form.errors

        else:
            profile_form = UserProfileForm()
    
    return render(request,
        'registration/profile_registration.html',
        {'profile_form': profile_form, 'registered': registered})
开发者ID:mhadam,项目名称:django-practice,代码行数:25,代码来源:views.py

示例7: 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)

        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()
开发者ID:kenju254,项目名称:tangowithdjango,代码行数:31,代码来源:views.py

示例8: register

def register(request):
	context=RequestContext(request)
	registered = False
	if(request.method=="POST"):
		#process the form
		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()#hashing the pwd
			profile=profile_form.save(commit=False)	
			profile.user=user#This is where we populate the user attribute of the UserProfileForm form, which we hid from users
			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:abnth,项目名称:tango_with_django_project,代码行数:26,代码来源:views.py

示例9: register

def register(request):
    registered = False
    print 'reg', request.method
    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 profile form errors', user_form.errors, profile_form.errors
    else:
        user_form=UserForm()
        profile_form = UserProfileForm()
    context = {'user_form': user_form, 'profile_form': profile_form,'registered': registered}
    print 'context', context
    return render(request, 'rango/register.html', context)
开发者ID:paula628,项目名称:tango_with_django_prac,代码行数:28,代码来源:views.py

示例10: edit_profile

def edit_profile(request):
   
    url = '/rango/'

    try:
        profile = request.user.userprofile
    except UserProfile.DoesNotExist:
        profile = UserProfile(user=request.user)

    if request.method == 'POST':
        profile_form = UserProfileForm(data=request.POST, instance=profile)
        if profile_form.is_valid():
            profile_form.save(commit=False)
            
            if 'picture' in request.FILES:
                print "picture"
                profile.picture = request.FILES['picture']
            
            profile.save()
            return redirect(url)

        else:
            print profile_form.errors

    else:
        profile_form = UserProfileForm(instance=profile)

    return render(request,
            'rango/edit_profile.html',
            {'profile_form': profile_form} )
开发者ID:WLBF,项目名称:tango_with_django_project,代码行数:30,代码来源:views.py

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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