A function or property in the model would do nicely. You can check this page
for more information:

http://www.b-list.org/weblog/2006/aug/18/django-tips-using-properties-models-and-managers/

<http://www.b-list.org/weblog/2006/aug/18/django-tips-using-properties-models-and-managers/>-
Paulo

On Fri, Aug 6, 2010 at 12:24 AM, flowpoke <bkeat...@gmail.com> wrote:

> I have a simple model that includes two DateField fields. I have
> everything passing to the template, as I would like but i'd like to
> add one more variable, duration. I want {{ duration }} to be that of
> the delta between the two DateField fields, in years. It's simple
> arithmetic but im not sure where to implement this logic. This is on a
> per object basis but it seems to me that I'd want to apply this logic
> at the model level, since it's a constant (i'll reference it anytime i
> call on this object(s)).
>
> Any pointers on where to begin? I suppose I can break this down in a
> view but im not sure how to unpack the QuertSet, add the new context
> variable to each object and then wrap it back up into a QuerySet. If
> thats even the right way to do 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.

Reply via email to