Hey!
I'm trying to select by foreign key, but for some reason it's not
working. Here's a bit of code to illustrate.
class FriendRequest(SQLObject):
requester = ForeignKey("User", dbName = "requester_id")
requested = ForeignKey("User", dbName = "requested_id")
But now I would like to select all the FriendRequests directed at a
certain user. So...
elver = get_user("elver")
requests = FriendRequest.select(FriendRequest.q.requested == elver)
However this bombs with:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File
"/usr/lib/python2.4/site-packages/SQLObject-0.8.0b2-py2.4.egg/sqlobject/sqlbuilder.py",
line 377, in __getattr__
raise AttributeError("%s instance has no attribute '%s'" %
(self.soClass.__name__, attr))
AttributeError: FriendRequest instance has no attribute 'requested'
Selecting itself works and the table exists and all that:
FriendRequest.select(FriendRequest.q.id == 1).count()
1/QueryOne: SELECT COUNT(*) FROM friend_request WHERE
((friend_request.id) = (1))
0L
How can I do a select by FriendRequest.requested?
Elver
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss