Hi Rob,

Rob Slotboom wrote:
> I found a solution using a custom query in models.py
> 
> def get_unvoted_polls_for_voter_ip(ip):
>    from django.db import connection
>    cursor = connection.cursor()
>    sql = """SELECT polls_poll.id, polls_poll.question FROM polls_poll
>       LEFT OUTER JOIN polls_vote ON polls_poll.id = polls_vote.poll_id
>       WHERE polls_vote.voter_ip <> '%s' OR polls_vote.voter_ip IS
> NULL;""" % ip
>    cursor.execute(sql)
>    list = cursor.fetchall()
>    return list
> 
> Now I want to create poll objects from the result but I dont know how.
> Any idea?

Hmm, there's a separate list for asking this type of questions, it's
django-users. You're welcome here, and often questions are answered
here, too, but here it is more for people developing and modifying
django, and these are a lot fewer than on the user list, especially at
this time of the day (hint, hint ;-)

That said, you probably want to do something like

poll = Poll(id=...,question=...)

or perhaps use the bulk_in method in QuerySet. There might exist better
(more elegant solutions), though, so better really re-raise your
question on the user list, or try something with dictfetchall.

Michael


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to