After digging through the messages here, I finally just did a custom
query. Here is the function I used that will spit out a template-ready
dictionary:
---------------
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
---------------------
it is called like so:
---------------------
qkeys = ['id','name']
query = "SELECT id, name FROM stuff"
div_list = csql(request,query,qkeys)
--------------------
In the template, it can be used like so:
-------------------
{% for div in div_list %}
this is an id: {{ div.id }}, this is a name {{ div.name }}
{% endfor %}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---