Hi all,
I have this function where i i use mssqlalchmy to to fetch data from a
mssql database. I am fetching data from a column but what i am interested
in, is just to get a data from last field/row on that column.
is there are way to get that done from template?. this what i have done
from the template.html but i am getting an error : could not parse the
remainder '[-1]'
template.html
<table class="table table-striped">
<thead>
<tr>
<th> GL Rate</th>
</thead>
</tr>
{%for a in results%}
<tr>
<td>{{a.buy_rate[-1]}}</td>
</tr>
{%endfor%}
</table>
view.py
def rate(request):
engine=create_engine('mssql+pymssql://username:passwprd@localhost
/database')
connection=engine.connect()
metadata=MetaData()
funds=Table('mccurtdt',metadata,autoload=True,autoload_with=engine)
stmt=select([funds.columns.buy_rate])
stmt=stmt.where(and_(funds.columns.rate_type=='MID',funds.columns.from_currency=='AUD',))
results=connection.execute(stmt).fetchall()
return render_to_response('rate.html',locals())
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CAPCf-y5EMP6qx59zzfQ-xx-7kz2QbUO%2Bq23pPvJdXTb0B9fdqw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.