2021年5月6日星期四

How to display specific user information in a separate page using flask and flask-sqlalchemy?

I made only one table in my application. I want to display some information on the page admin.html and specific user information on info.html page. How should I give the query to show the particular user information on which client has clicked on the admin page. I want to display other attributes of my database like email, phone number, college name only on the info.html page. Here are my files:

database

class database(db.Model):      id=db.Column('user_id',db.Integer, primary_key=True)      name = db.Column(db.String(20))      text=db.Column(db.String(1000))      personality_score=db.Column(db.Integer)      skills_score=db.Column(db.Integer)      experience_score=db.Column(db.Integer)      total_score=db.Column(db.Integer)      college=db.Column(db.String(100))      email=db.Column(db.String(100))      phone_number=db.Column(db.String(100))  

app.py

@app.route('/admin')  def admin():      return render_template('admin.html',database=database.query.order_by(database.total_score.desc()).all())    @app.route('/info')  def info():      return render_template('info.html')  

admin.html

<table class="css-serial">           <tbody>              <tr>                 <th>Rank</th>                 <th>ID</th>                 <th>Name</th>                 <th>Profile Summary</th>                 <th>Personality Score</th>                 <th>Skills Score</th>                 <th>Experience Score</th>                 <th>Total Score</th>              </tr><tr>                         </table>  

I have not written anything in the info.html file because I was not able to figure out how to fetch 'id' or data to display on that page.

https://stackoverflow.com/questions/67428672/how-to-display-specific-user-information-in-a-separate-page-using-flask-and-flas May 07, 2021 at 11:32AM

没有评论:

发表评论