1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # custom query function:
def csql(self,query,qkeys):
from django.db import connection
cursor = connection.cursor()
cursor.execute(query)
rows = cursor.fetchall()
# build dict for template:
fdicts = []
for row in rows:
i = 0
cur_row = {}
for key in qkeys:
cur_row[key] = row[i]
i = i+1
fdicts.append(cur_row)
return fdicts
|
More like this
- Last.fm Charts by sedden 4 years, 10 months ago
- Global custom permissions (no model association) by miracle2k 5 years, 10 months ago
- Easier chainability with custom QuerySets by bendavis78 1 year, 2 months ago
- View decorator to automate templates. by jafo 3 years, 3 months ago
- Admin: ordering by multiple fields in a column sort by benatkin 2 years, 10 months ago
Comments