Hello,
I have the following situation:
A Blog has Comments and Trackbacks. Trackbacks should be shown like
comments but they get a div class="Trackback" instead of
class="Comment" in HTML.
My idea was to join all Trackbacks and Comments and use a an
additional attribute to tell them apart in HTML:
def commentList(self):
""" Returns a joined list of comments and trackbacks, ordered
descending by date. """
comments = self.comment_set.all()
trackbacks = self.trackback_set.all()
joined = (comments + trackbacks).sort(cmp = lambda x,y:
cmp(x.creationDate, y.creationDate), reverse = true)
for j in joined:
if isinstance(j, Comment):
j.type = "Comment"
elif isinstance(j, Trackback):
j.type = "Trackback"
return j
Ok, that does not work, because you can't concat to QuerySets like
that. I think that this solution would not be optimal anyway.
How would you do this task?
Thanks,
Florian
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" 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-users?hl=en
-~----------~----~----~----~------~----~------~--~---