我有 3 个模型,我需要它们的一些列:class candidates(db.Model): id = db.Column(db.Integer, primary_key = True, autoincrement=True, nullable=False) name = db.Column(db.String(50), nullable= False) surname = db.Column(db.String(50), nullable= False) father_name = db.Column(db.String(50), nullable= False) class students(db.Model): id = db.Column(db.Integer, primary_key = True, autoincrement=True, nullable=False) candidate_id = db.Column(db.Integer, db.ForeignKey('candidates.id'), nullable= False) # Foreign key to Candidates type = db.Column(db.Integer, nullable= False) family_status = db.Column(db.Boolean(), nullable= False) education_status = db.Column(db.Boolean(), nullable= False)class graduate_students(db.Model): id = db.Column(db.Integer, primary_key = True, autoincrement=True, nullable=False) student_id = db.Column(db.Integer, db.ForeignKey('students.id'), nullable= False) work_place = db.Column(db.String(255), nullable= False) salary = db.Column(db.Integer, nullable= False)result = graduate_students.query.with_entities( graduate_students.id, students.id, candidates.id, candidates.name, candidates.surname).join(students).join(candidates).all()print(result)但解释器给了我这个错误:“无法确定要加入哪个 FROM 子句” sqlalchemy.exc.InvalidRequestError:无法确定要从哪个 FROM 子句加入,有多个 FROM 可以加入到该实体。请使用 .select_from() 方法建立显式左侧,并提供显式 ON 子句(如果尚不存在)以帮助解决歧义。
1 回答
汪汪一只猫
TA贡献1898条经验 获得超8个赞
if request.method == "POST":
form = QuestionForm(request.POST or None)
if form.is_valid():
new_question = form.save()
student = Student.objects.get(user = request.user)
new_question.student = student
new_question.save()
if((len(request.FILES) =
添加回答
举报
0/150
提交
取消