每个人。任何人。下面是我的 models.py 文件,我在数据库中创建了一个表
class Staff(UserMixin, MongoModel):
full_name = fields.CharField(required=True, blank=False)
job_position = fields.CharField(required=True, blank=False)
email = fields.EmailField(required=True, blank=False)
password = fields.CharField(required=True, blank=False)
def get_id(self):
return str(self.pk)
我正在使用烧瓶登录进行登录身份验证
login_manager = LoginManager()
login_manager.login_view = 'login'
login_manager.init_app(app)
@login_manager.user_loader
def load_user(staff_id):
staff = Staff.objects.get({"_id": ObjectId(staff_id)})
return staff
这是登录页面的路径
@app.route("/login", methods=['GET', 'POST'])
def login():
form = LoginForm()
if form.validate_on_submit():
email = form.email.data
password = form.email.data
remember = form.remember.data
staff = Staff.objects.raw({"email": email, "password": password})
if staff.count() == 0:
return "Invalid email or password"
login_user(staff.first())
remember = remember
return redirect(url_for('dashboard'))
return render_template("login.html", form=form)
它返回一个model.DoesNotExist,它显然存在,但我一定做错了什么