On 12/18/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I can do that for the recent topics (was trying not to, thinking it
> would be more efficient to handle it in the view), but what about
> something like last_seen, which is different for each user, as it's
> calculated from their session:
> if i.topic_modification_date > request.session['last_seen']:
>           i.last_seen = "New"
>
> Is there any way to pass that info to a generic view?

Because generic view uses a queryset (which it clones at the very
start causing your original problem) the only way (I can think of)
would be to write your own Manager which returned Post objects
annotated with your new flag. Never played with custom Managers yet so
I could be talking rubish...

Another equally complex solution would be a custom templatetag since
it would be in a position to see both the object and the context from
(which it could get last_seen).

If there was an {% ifgreater a b %} tag you could use that. I could
not find any matches in google for that but you can use the expr tag
(non-standard) to the same effect.

See http://code.djangoproject.com/wiki/ExprTag

I think you would need to pass last_seen in via extra_context and do:

{% expr object.topic_modification_date > last_seen as newflag %}
{% if newflag %}
   <strong>NEW!</strong>
{% endif %}


Cheers,

-- 
Phil Davis

--~--~---------~--~----~------------~-------~--~----~
 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