0 Replies - 329 Views - Last Post: 05 September 2013 - 04:07 AM Rate Topic: -----

#1 Orochimaru  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 47
  • Joined: 26-December 12

Output this variable when used in an MVC?

Posted 05 September 2013 - 04:07 AM

How can I output the contents of desc? I want to see what that data looks like with my own eyes.
desc = cursor.description


But since dictfetchall(cursor) only have content when it's called by
class AltwordManager(models.Manager):
    def vote_order(self):

I'm not really sure which part of the MVC files I need to edit in order to output the desc variable directly. Is it the below models.py file, views.py or the html template file?

And when I know which of these 3 files I need to edit, how do I reveal the contents of variable desc onto my screen?
MVC coding makes me really confused about how things are connected... :blink:


#_______________________________________________________________________________
https://docs.djangoproject.com/en/1.6/topics/db/sql/#connections-and-cursors

def dictfetchall(cursor):
    "Returns all rows from a cursor as a dict."
    desc = cursor.description # <------------------------ ( I want to output this content on my screen! )
    return [
        dict(zip([col[0] for col in desc], row))
        for row in cursor.fetchall()
    ]
#_______________________________________________________________________________

class AltwordManager(models.Manager):
    def vote_order(self):
        "Returns a 1:M list ordered by votes."
        cursor =  connection.cursor()
        cursor.execute("""
SELECT navi_polls_word.rosword, navi_polls_altword.alt_ros_word, navi_polls_altword.votes
FROM navi_polls_altword INNER JOIN navi_polls_word
ON (navi_polls_altword.rosword_id=navi_polls_word.id)
        """)
        #row = cursor.fetchall()
        row = dictfetchall(cursor)
        return row
#_______________________________________________________________________________


Is This A Good Question/Topic? 0
  • +

Page 1 of 1