Ah sorry yeah, I forgot you needed @staticmethod decorator on the class
method.

To be honest though, that method should be a standalone function, not a
method (as James said, you need to re-think your approach!)

Cal


On Sun, Sep 8, 2013 at 9:25 PM, Pepsodent Cola <pepsodentc...@gmail.com>wrote:

> Hi Cal,
>
> I replaced the code with this:
>         row = AltwordManager.dictfetchall2(cursor)
>
> Then I got a different error message that I don't understand?
> ExceptionValue:
>
>
>
>
> unbound method dictfetchall2() must be called with AltwordManager instance as 
> first argument (got CursorDebugWrapper instance instead)
>
>
>
>
>
>
>
> On Sunday, September 8, 2013 9:54:36 PM UTC+2, Cal Leeming [Simplicity
> Media Ltd] wrote:
>
>> Try and replace
>> row = dictfetchall2(cursor)
>>
>> With this
>> row = AltwordManager.dictfetchall2(**cursor)
>>
>> Cal
>>
>>
>> On Sun, Sep 8, 2013 at 8:23 PM, Pepsodent Cola <pepsod...@gmail.com>wrote:
>>
>>> I don't understand how to fix this error message?  Here is the code that
>>> made things break.
>>>
>>> Exception Value: global name 'dictfetchall2' is not defined
>>>
>>>
>>>
>>> #_____________________________**______________________________**
>>> ____________________
>>>
>>> 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()
>>>     ]
>>> #_____________________________**______________________________**
>>> ____________________
>>>
>>> class AltwordManager(models.Manager)**:
>>> *    def dictfetchall2(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()
>>>         ]
>>>
>>>     def vote_order(self):
>>>         "Returns a 1:M list ordered by votes."
>>>         cursor =  connection.cursor()
>>>         cursor.execute("""
>>> SELECT navi_polls_word.rosword
>>> FROM navi_polls_altword
>>>         """)
>>>         #row = cursor.fetchall()
>>>         #row = dictfetchall(cursor)
>>> *        row = dictfetchall2(cursor)*
>>>         return row
>>>
>>> ...
>>> ...
>>> #_____________________________**______________________________**
>>> ____________________
>>>
>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@**googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>>
>>> Visit this group at 
>>> http://groups.google.com/**group/django-users<http://groups.google.com/group/django-users>
>>> .
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>> .
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to