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


Python UserCreateForm.save方法代码示例

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


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

示例1: register

# 需要导入模块: from forms import UserCreateForm [as 别名]
# 或者: from forms.UserCreateForm import save [as 别名]
def register(request):
	context = {}
	context["news"] = get_news_by_request(request)
	user = User()
	if request.method == 'POST':
		form = UserCreateForm(request.POST, instance = user)
		if form.is_valid():
			pw = user.password
			user.set_password(user.password)
			user.theme_id=4
			user.input_type_id=1
			if not open_registration:
				user.is_active = False
			form.save()
			ro = ReminderOffsets.objects.get(value=0)
			user.reminder_offset.add(ro)
			ro = ReminderOffsets.objects.get(value=2)
			user.reminder_offset.add(ro)
			if open_registration:
				group = Group.objects.filter(name="BuLiTipp")[0]
				user.groups.add(group)
				user = authenticate(username=user.username, password=pw)
				djlogin(request, user)
				messages.success(request, "Benutzer erfolgreich angelegt! Tritt als nächstes einer Tippgemeinschaft bei!")
				return HttpResponseRedirect(reverse("user", args=["tgchange"]))
			else:
				mail.send("BuLiTipp: User registriert", "[email protected]", "Bitte administriere den neuen User " + user.username+ " !")
				messages.success(request, "Benutzer erfolgreich angelegt! Du kannst dich einloggen sobald der Administrator dich freigeschaltet hat.")
				return HttpResponseRedirect(reverse("home"))
			
	else:
		form = UserCreateForm(instance=user)
	context["form"] = form
	return render(request, 'registration/register.html', context)
开发者ID:laDanz,项目名称:BuLiTipp,代码行数:36,代码来源:views.py

示例2: signup

# 需要导入模块: from forms import UserCreateForm [as 别名]
# 或者: from forms.UserCreateForm import save [as 别名]
def signup(request):
    """
    User registration view.
    """
    auth_form = AuthenticateForm()

    if request.method == 'POST':
        form = UserCreateForm(data=request.POST)
        if form.is_valid():
            form.save()
            user = authenticate(email=request.POST['email'], password=request.POST['password2'])
            if user is not None:
                if user.is_active:
                    login(request, user)
                    return redirect('/')

        else:
            return render_to_response('home.html', {
                'auth_form': auth_form, 'user_form': form, 
            }, context_instance=RequestContext(request))

    elif request.method == 'GET':
        form = UserCreateForm()
        return render_to_response('home.html', {
            'auth_form': auth_form, 'user_form': form, 
        }, context_instance=RequestContext(request))
开发者ID:KophyGiddie,项目名称:Tweetify,代码行数:28,代码来源:views.py

示例3: register_user

# 需要导入模块: from forms import UserCreateForm [as 别名]
# 或者: from forms.UserCreateForm import save [as 别名]
def register_user(request):
    
    template_name = 'kitchen/crispy.html'

    if request.method == 'POST':
        user_form = UserCreateForm(request.POST)
        if user_form.is_valid():
            username = user_form.clean_username()
            password = user_form.clean_password2()
            user_form.save()
            
            user = authenticate(username=username,
                                password=password)
            if user:
                # save extra parameters - email
                user.email = user_form.data['email']
                user.save()
                #ASK - may be we should init it only in one place - on login?
                initUser(user)
                login(request, user)
                return redirect('account-list')
        return render(request,
                      template_name,
                      { 'form' : user_form })
    args = {}
    args.update(csrf(request))
    args['form'] = UserCreateForm()
    print args
    return render(request, template_name, args)
开发者ID:CrowdCafe,项目名称:CrowdKitchen,代码行数:31,代码来源:views.py

示例4: new_user

# 需要导入模块: from forms import UserCreateForm [as 别名]
# 或者: from forms.UserCreateForm import save [as 别名]
def new_user(request):
    if request.method=='POST':
        formulario = UserCreateForm(request.POST)
        if formulario.is_valid:
            formulario.save()
            return HttpResponseRedirect('/')
    else:
        formulario = UserCreateForm()
    return render_to_response('new_user.html',{'formulario':formulario},context_instance=RequestContext(request))
开发者ID:gbarbosa4,项目名称:Concessionari,代码行数:11,代码来源:views.py

示例5: create_account

# 需要导入模块: from forms import UserCreateForm [as 别名]
# 或者: from forms.UserCreateForm import save [as 别名]
def create_account(request):
    if request.method == "POST":
        form = UserCreateForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/success/')
    else:
        form = UserCreateForm()
    return render(request,'create.html',{'form':form})
开发者ID:pgp-pasteur-fr,项目名称:MetaGenSense,代码行数:11,代码来源:views.py

示例6: signup

# 需要导入模块: from forms import UserCreateForm [as 别名]
# 或者: from forms.UserCreateForm import save [as 别名]
def signup(request, template_name="authentication/signup.html"):
    form = UserCreateForm(request.POST or None)

    if request.POST:
        if form.is_valid():
            form.save()

            return HttpResponseRedirect(reverse("home"))

    return render(request, template_name, {"form": form})
开发者ID:dogancankilment,项目名称:MViG,代码行数:12,代码来源:views.py

示例7: create_user

# 需要导入模块: from forms import UserCreateForm [as 别名]
# 或者: from forms.UserCreateForm import save [as 别名]
def create_user(request):
    """Creates a new user"""
    if request.method == "POST":
        form = UserCreateForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/')
    else:
        form = UserCreateForm()
    return render(request, 'quiz/create_user.html', context={'form': form})
开发者ID:Jasonbhaas,项目名称:Quiz-Project,代码行数:12,代码来源:views.py

示例8: register

# 需要导入模块: from forms import UserCreateForm [as 别名]
# 或者: from forms.UserCreateForm import save [as 别名]
def register(request):
    register_success = reverse('user_register_success')
    if request.method == 'POST':
		form = UserCreateForm(request.POST)
		if form.is_valid():
			form.save()
			return HttpResponseRedirect(register_success)
    else:
		form = UserCreateForm()
    return render_to_response('newaccounts/registration.html', {'form':form}, context_instance=RequestContext(request))
开发者ID:mtmarsh2,项目名称:InstaSellProject,代码行数:12,代码来源:views.py

示例9: register

# 需要导入模块: from forms import UserCreateForm [as 别名]
# 或者: from forms.UserCreateForm import save [as 别名]
def register(request):
    if request.user.is_authenticated():
        
        return redirect('/')

    if request.method == 'POST':
        user_information = {
        'username': request.POST['username'],
        'password1': request.POST['password1'],
        'password2': request.POST['password2'],
        'last_name': request.POST['last_name'],
        'city': request.POST['city'],
        'first_name': request.POST['first_name'],
        'state': request.POST['state'],
        'middle_initial': request.POST['middle_initial'],
        'birth_date': request.POST['birth_date'],
        'email': request.POST['email'],
        'street_address': request.POST['street_address'],
        'zip_code': request.POST['zip_code']
        }

        form = UserCreateForm(user_information)
        if form.is_valid():
           
            form.save()
            return redirect('/') 
        else: 
            form_errors = form.errors
            return render_to_response('register.html', {'errors': form_errors, 'form': form}, context_instance=RequestContext(request))
    else: #AJAX form validation
        request_copy = request.GET.copy()
      

        if 'username' in request_copy: #Username in use?
            name = request_copy['username']
            response_data = {}

            if UserProfile.objects.filter(username__iexact=name): 
                response_data['result'] = 'false'
            else:           
                response_data['result'] = 'true'
            return HttpResponse(response_data['result'], content_type='text/plain')
          
            # return HttpResponse(json.dumps(response_data), content_type = "application/json")
        if 'email' in request_copy: #Email in use?
            entered_email = request_copy['email']
            response_data = {}
            if UserProfile.objects.filter(email__iexact=entered_email):
                response_data['result'] = 'false'
            else:
               response_data['result'] = 'true'
            return HttpResponse(response_data['result'], content_type = 'text/plain')
        else:
            form = UserCreateForm()
            return render_to_response("register.html", {'form': form, 'errors':form.errors}, context_instance=RequestContext(request))
开发者ID:rmwdeveloper,项目名称:rainforest,代码行数:57,代码来源:views.py

示例10: post

# 需要导入模块: from forms import UserCreateForm [as 别名]
# 或者: from forms.UserCreateForm import save [as 别名]
	def post(self, request):
		form = UserCreateForm(request.POST)
		if form.is_valid():
			form.save()
			request.session["temp_user"] = {
				'username': request.POST["username"],
				'new': True,
			}
			return redirect('/accounts/register/done/')
		else:
			return render(request, self.template_name, {'user_create_form': form})
开发者ID:ryanoflaherty,项目名称:OpenEMR-API,代码行数:13,代码来源:views.py

示例11: settings

# 需要导入模块: from forms import UserCreateForm [as 别名]
# 或者: from forms.UserCreateForm import save [as 别名]
def settings(request):
    tweet_form = TweetForm()
    if request.method == 'POST':
        form = UserCreateForm(request.POST)
        if form.is_valid():
            form.save()
            return redirect('/')
        else:
            return render(request, 'settings.html', {'form': form,})
    form = UserCreateForm(instance=request.user)
    return render(request, 'settings.html', {'form': form, 'tweet_form': tweet_form})
开发者ID:KophyGiddie,项目名称:Tweetify,代码行数:13,代码来源:views.py

示例12: signup

# 需要导入模块: from forms import UserCreateForm [as 别名]
# 或者: from forms.UserCreateForm import save [as 别名]
def signup(request, template_name="registration/signup.html"):
    if request.user.is_authenticated():
        messages.warning(request, 'Logout to create a new user')
        return redirect('/')
    else:
        form = UserCreateForm(request.POST or None)
        if form.is_valid():
            form.save()
            messages.success(request,
                             'User Account Created. Please proceed to login.')
            return redirect('/login/')
        return render(request, template_name, {'form': form})
开发者ID:ABYARTH,项目名称:JHTS,代码行数:14,代码来源:views.py

示例13: signup

# 需要导入模块: from forms import UserCreateForm [as 别名]
# 或者: from forms.UserCreateForm import save [as 别名]
def signup(request):
    user_form = UserCreateForm(data=request.POST)
    if request.method == 'POST':
        if user_form.is_valid():
            username = user_form.clean_username()
            password = user_form.clean_password2()
            user_form.save()
            user = authenticate(username=username, password=password)
            login(request, user)
            return redirect('/')
        else:
            return index(request, user_form=user_form)
    return redirect('/')
开发者ID:krist-jin,项目名称:DB_project,代码行数:15,代码来源:views.py

示例14: registro

# 需要导入模块: from forms import UserCreateForm [as 别名]
# 或者: from forms.UserCreateForm import save [as 别名]
def registro(request):
    if request.method == 'POST':
        formulario = UserCreateForm(request.POST)
        if formulario.is_valid:
            formulario.save()
            u = User.objects.get(username=request.POST['username'])
            u.is_active=False
            u.save()
            usuario = Usuarios(usuario=u)
            usuario.save()
            return HttpResponseRedirect('/usuario/editar/')
    else:
        formulario = UserCreateForm()
    context={"formulario":formulario}
    return render_to_response('usuario/registro.html', context, context_instance=RequestContext(request))
开发者ID:fernandoguirao,项目名称:joinity_old,代码行数:17,代码来源:views.py

示例15: customregister

# 需要导入模块: from forms import UserCreateForm [as 别名]
# 或者: from forms.UserCreateForm import save [as 别名]
def customregister(request):
    returnJson = ifReturnJson(request)
    data_dict = {}
    data_dict['type'] = 'register'
    if request.method == 'POST':
        form = UserCreateForm(request.POST)
        if form.is_valid():
            new_user = form.save()

            data_dict['success'] = 1
            data_dict['uid'] = new_user.id
            data_dict['username'] = new_user.username
            data_dict['name'] = new_user.first_name + new_user.last_name
            data_dict['email'] = new_user.email

            #Redirect to the registration complete page
            #return HttpResponseRedirect("/homepage/")
        else:
            data_dict['success'] = 0
            #invalid form
            data_dict['error_message'] = 'invalid registration form'
        if returnJson == 1:
            return HttpResponse(json.dumps(data_dict),content_type='application/json')
        elif returnJson == 0:
            return redirect('/accounts/register')
    else:
        form = UserCreateForm()
        return render(request, "registration/registration_form.html", {
            'form': form,
        })
开发者ID:ZhigangAndyWang,项目名称:FoodJournal,代码行数:32,代码来源:views.py


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