On 11/11/06, Rob Slotboom <[EMAIL PROTECTED]> wrote:
>    return [Poll.__class__(*row) for row in cursor.fetchall()]

This is the problematic line; to instantiate a Poll, you'll want to
either call its constructor -- Poll() -- or use the 'create()' method
of its default manager (probably 'Poll.objects.create()', but
'Poll._default_manager.create()' should work as well).

Poll() will accept a list of values, but the order it expects and the
order in which the values come back from the database may not
correspond, which could mean you'll end up with a mismatch between
values and the fields they're trying to fit into. The docstring of the
Poll model will tell you the order in which it expects field values to
occur if you pass positional arguments or an unpacked list.

But the safest method is probably to build a dictionary from the
returned data set and use that as the argument to Poll() (using the
'**' unpacking instead of '*', of course). The 'create' method of the
manager, IIRC, will only accept keyword arguments, so passing them as
name=value pairs or as an unpacked dict is the only way to use it.


-- 
"May the forces of evil become confused on the way to your house."
  -- George Carlin

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to