我在Django proj中有python语法错误

2024-04-25 05:35:01 发布

您现在位置:Python中文网/ 问答频道 /正文

首先,我是django和python的初学者 我想注册和登录服务,但我有python语法错误

我使用python3.7.3

from django.shortcuts import render from django.contrib.auth.models import User from django.contrib import auth def signup(request): if request.method == "POST" : if request.POST["password1"] == request.POST["password2"] : user = User.objects.create_user{ username=request.POST["username"], password = request.POST["password"] if user is not None: auth.login(request,user) return redirect['home'] else: return render(request, 'login.html', {'error': 'username or password is incorrect'}) else: return render(request,'login.html') }

在第8行中,(用户=User.objects.create\u用户)我有语法错误 帮助我!你知道吗


Tags: djangofromimportauthreturnifrequestusername
1条回答
网友
1楼 · 发布于 2024-04-25 05:35:01

你在这里犯错误

user = User.objects.create_user{
                username=request.POST["username"], password = request.POST["password"]

试试这个

user = User.objects.create_user(username=request.POST["username"],password = request.POST["password"])

相关问题 更多 >