I'm developing a Pymongo project using Flask Framework. I want to fetch data and assign it to a variable something like this.
dOcName = select name from doctors where dname = "<some_name>";
Below is my Flask and html code when i run, I'm getting printed <pymongo.cursor.Cursor object at 0x000000000433DB38>
in my textbox.
app.py:
@app.route('/dochome',methods=['POST','GET'])
def dochome():
if request.method == 'POST':
if len(session) == 0:
return render_template('login.html')
uname = session['username']
dOcName = db.doctors.find({'dname': uname},{'name':1, '_id':0})
return render_template('dochome.html', dname = uname, dOcName = dOcName)
dochome.html:
<form method="post" action="{{ url_for('dochome') }}">
<div class="container">
<h3>WELCOME: Doctor. <input class="form-control" type="text" name="docName" value="{{ dOcName }}" readonly></h3>
</div>
</form>
Any idea what I am doing wrong/how I can get dOcName I am looking for?
Thanks in advance