0 Replies - 286 Views - Last Post: 09 September 2013 - 04:16 AM Rate Topic: -----

#1 Orochimaru  Icon User is offline

  • New D.I.C Head

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

[MVC/MTV] - How can I send variable from Model to Detail.html?

Posted 09 September 2013 - 04:16 AM

This is my Models code and I want to output the contents of variable blackbox to my screen.

1.) Do I need to write some code in Views.py to transfer my variable "blackbox" from Models to Views to Detail.html?
2.) Or can I access my variable "blackbox" directly from Detail.html?


class AltwordManager(models.Manager):
    def dictfetchall2(self, p):
        "Returns all rows from a cursor as a dict."
        desc = p.description
        self.dark = desc
        return [
            dict(zip([col[0] for col in desc], row))
            for row in p.fetchall()
        ]

    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)
ORDER BY votes DESC
        """)
        #row = cursor.fetchall()
        #row = dictfetchall(cursor)
        row = AltwordManager.dictfetchall2(self, cursor)
        blackbox = self.dark
        return blackbox



Is This A Good Question/Topic? 0
  • +

Page 1 of 1