def add_User(request): form = UserCreateForm() if request.method == "POST": form = UserCreateForm(request.POST) if form.is_valid(): form.save() return redirect("home") return render_to_response("add_User.html", {"form": form}, RequestContext(request))
def add_User(request): form = UserCreateForm() if request.method == 'POST': form = UserCreateForm(request.POST) if form.is_valid(): form.save() return redirect('home') return render_to_response('add_User.html', { 'form': form, }, RequestContext(request))
def registro(request): form = UserCreateForm if request.method == 'POST': form = UserCreateForm(request.POST) if form.is_valid(): user = form.save() UserProfile.objects.create(user=user) return redirect('login') return render_to_response('registro.html', { 'form': form, }, RequestContext(request))
def signup(): form = UserCreateForm() if request.method == 'POST' and form.validate_on_submit(): # 쿼리 결과가 여러개인 경우 첫번째 레코드를 반환한다. one()은 결과 값이 한 개인 경우 사용한다. 여러개이면 예외가 발생한다. user = User.query.filter_by(username=form.username.data).first() if not user: user = User(username=form.username.data, # password=generate_password_hash(form.password1.data), password=_pwhash(form.password1.data), email=form.email.data) db.session.add(user) db.session.commit() return redirect(url_for('main.index')) else: flash('이미 존재하는 사용자입니다.') return render_template('auth/signup.html', form=form)
def Registration(request): if request.user.is_authenticated(): return HttpResponseRedirect('/profile/') if request.method == 'POST': form = UserCreateForm(request.POST) if form.is_valid(): user = User.objects.create_user(username=form.cleaned_data['username'], email=form.cleaned_data['email'], password=form.cleaned_data['password1']) user.save() users = UserProfile(user=user, name=form.cleaned_data['name'], birthday=form.cleaned_data['birthday'], location=form.cleaned_data['location'], bio=form.cleaned_data['bio'], private=form.cleaned_data['private']) users.save() return redirect('LoginRequest') else: return render_to_response('register.html', {'form': form}, context_instance=RequestContext(request)) else: ''' user is not submitting the form, show them a blank registration form ''' form = UserCreateForm() context = {'form': form} return render_to_response('register.html', context, context_instance=RequestContext(request))
def signup(request): 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) login(request, user) return redirect("/") else: return render(request, 'main/signup.html', { 'form' : user_form }) return render(request, 'main/signup.html')