Comparing values from multiple tables; *show new posts* forum feature

2009-01-18 Thread Piotr Husiatyński

Hello,
I'm writing forum and I have a problem with *show new posts* feature.
Here's the code of my application:

http://github.com/husio/arch-pl/tree/09234f6d780c76b45b5e1a6576d80080507873d4/forum

I have two tables for *new* posts
- AllVisited for marking all posts as visited
- VisitedThread for remembering each post that user has seen

Line ~70 of view.py file is the incomplete question

dt = search_date_limit
unreaded = Thread.objects.filter(
Q(latest_post_date__gt=dt),
Q(visitedthread__isnull=True) |
Q(visitedthread__isnull=False,
  visitedthread__date__lt= ? )  #
thread__latest_post_date ?
).distinct()[offset:offset + number]

The only thing I don't know how to do is how to check each
Thread.latest_post_date value during sql select and compare it with
VisitedThread.date value. How to write it?
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Comparing values from multiple tables; *show new posts* forum feature

2009-01-22 Thread Piotr Husiatyński

On 18 Sty, 12:06, Malcolm Tredinnick  wrote:
> Wait a few days until ticket #7210 is resolved and you'll be able to use
> references to other fields as rhs values in filters. The work for that
> is nearly complete, so it's pretty close to being committed. I'm fairly
> sure that will help you there.

You mean #7210 http://code.djangoproject.com/ticket/7210 : "Added
expression support for QuerySet.update"
How that could solve my problem?
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---