On Fri, Jun 3, 2011 at 11:29 AM, Marc Aymerich <glicer...@gmail.com> wrote:
> On Fri, Jun 3, 2011 at 8:30 AM, Amit Sethi <amit.pureene...@gmail.com> wrote:
>>> functionality to your models. (For "row-level" functionality -- i.e.,
>>> functions that act on a single instance of a model object -- use Model
>>> methods, not custom Manager methods.)
>>>
>>
>> But what is the benefit of model methods compared to adding an extra
>> field and getting almost the same thing done
>>
>
> Maybe the result value depends on some parameters, If you use the DB
> field approach, and you want to keep up to date these values, you need
> to execute some expensive "regenerator" method each time that one of
> these parameters change, with Managers you don't need to do anything.
>
> If you use DB approach you need to populate these extra fields every
> time that a new object is saved, and maybe never uses it.

Realise that you need to update the field every time that an object is
updated. So at the end, if you compare all the time needed to keep
updated this field and all the time used by the Manager to generate
it, most of the time will be the manager who uses less time.




-- 
Marc

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

Reply via email to