Hi,
I need to use a raw SQL query and populate a table2 table with the results.
The query works fine and returns a list of Dicts using this function from 
the helpfile <https://docs.djangoproject.com/en/dev/topics/db/sql/>:

def dictfetchall(cursor):
    "Returns all rows from a cursor as a dict"
    desc = cursor.description
    return [
        dict(zip([col[0] for col in desc], row))
        for row in cursor.fetchall()
    ]

My issue is that I cannot figure out how to populate a Table2 table with 
this info.  Table2 <http://django-tables2.readthedocs.org/en/latest/#>suggests 
this a way to achieve my goal, but I can't figure it out. 

import django_tables2 as tables
data = [
    {"name": "Bradley"},
    {"name": "Stevie"},]
class NameTable(tables.Table):
    name = tables.Column()
table = NameTable(data)


Your help would be much appreciated.  Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/q9Q9X1JtjZwJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to