@csrf_exempt
def signup(request):
if request.method == 'GET':
user = request.user.is_authenticated
if user:
return redirect('/main')
else:
return render(request, 'user/signup.html')
elif request.method == "POST":
username = request.POST.get('username','')
userpw = request.POST.get('userpw','')
userpw2 = request.POST.get('userpw2','')
user = request.POST.get('user','')
# userimg = request.POST.get('userimg','')
useremail = request.POST.get('useremail','')
phone = request.POST.get('phone','')
bio = request.POST.get('bio','')
if userpw != userpw2:
return render(request, 'user/signup.html',{'error':'패스워드를 확인해주세요!'})
else:
if username == '' or userpw == '':
return render(request, 'user/signup.html',{'error':'사용자 이름과 비밀번호는 필수입니다!'})
exist_user = get_user_model().objects.filter(username=username)
if exist_user:
return render(request, 'user/signup.html',{'error':'사용자가 이미 존재합니다!'})
else:
user_table = UserModel()
user_table.username=username
user_table.set_password(userpw2)
user_table.user=user
# user_table.user_img=userimg
user_table.email=useremail
user_table.phone=phone
user_table.bio=bio
user_table.save()
return redirect('/login')
회원가입
def profileupdate(request):
if request.method == "POST":
user_table = request.user
user_table.phone=request.POST.get('phone'," ")
user_table.password=request.POST.get('userpw'," ")
user_table.user_id=request.POST.get('user_id'," ")
user_table.email=request.POST.get('useremail'," ")
# user_table.user_img=request.POST.get('userimg'," ")
user_table.bio=request.POST.get('bio'," ")
user_table.set_password(user_table.password)
user_table.user_id=user_table.user_id
# user_table.user_img=user_table.user_img
user_table.email=user_table.email
user_table.phone=user_table.phone
user_table.bio=user_table.bio
user_table.save()
return redirect('/')
return render(request, 'user/profileupdate.html')
회원정보수
'스파르타코딩개발일지' 카테고리의 다른 글
KPT 팀 프로젝트 회고록. (0) | 2022.10.06 |
---|---|
검색기능구현 (0) | 2022.10.06 |
삭제후 재설치 (0) | 2022.10.01 |
8번방의 선물 TeamProjecT 인스타그램 클론코딩 (0) | 2022.09.29 |
git bash > branch> full request (0) | 2022.09.29 |