예제 #1
0
def register(request):
    if request.method=='GET':
        return render(request, 'member/register.html', {'userForm':UserForm()})
    #POST
    userForm = UserForm(request.POST)
    if not userForm.is_valid():
        return render(request, 'member/register.html', {'userForm': userForm})
    user = userForm.save()
    user.set_password(user.password)
    user.save()
    messages.success(request, '註冊成功')
    return redirect(reverse('userLogin:userLogin'))
예제 #2
0
def manager(request):
    if request.method=='GET':
        return render(request, 'member/manager.html', {'userForm':UserForm(instance=request.user)})
    #POST
    userForm = UserForm(request.POST, instance=request.user)
    if not userForm.is_valid():
        return render(request, 'member/manager.html', {'userForm': userForm})
    user = userForm.save()
    user.set_password(user.password)
    user.save()
    messages.success(request, '修改成功,請重新登入')
    return redirect('about/idea.html')