def register(request): if request.method == 'GET': return render(request, 'register.html') elif request.method == 'POST': user = User() user.username = request.POST.get('username') user.password = genarate_password(request.POST.get('password')) user.token = str(uuid.uuid5(uuid.uuid4(), 'register')) user.save() request.session['token'] = user.token return redirect('app:index')
def register(request): if request.method == 'GET': return render(request,'mine/register.html') elif request.method == 'POST': user = User() user.email = request.POST.get('email') user.password = generate_password(request.POST.get('password')) user.name = request.POST.get('name') user.phone = request.POST.get('phone') # 状态保持 user.token = generate_token() user.save() request.session['token'] = user.token return redirect('axf:mine')