On Mon, 2007-06-04 at 01:27 +0000, [EMAIL PROTECTED] wrote:
> I've been working with .91-bugfixes for a long time, and moving into
> the development version makes me feel like a stranger lost in a
> wonderful, yet foreign, country. I have no doubt all the changes are
> for the better, but I'm a little tripped up on managers. (probably
> because I never fully grasped _module methods)
> 
> DjangoBook gives me a few examples in Chapter 15, but refer to chapter
> 5, which doesn't have anything about managers in it.
> 
> >From the docs:
> > Adding extra Manager methods is the preferred way to add "table-level" 
> > 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.)
> 
> I'm not sure what this means. Can anyone explain what is meant by
> "table-level" functionality or provide a simple  example? (and again
> for row-level?)

Manager methods are things that operate on the whole collection of model
instances. Model methods, on the other hand, only operate on the
particular instance that they are bound to.

So you could use a manager method if you need something that returns a
list or a set of model instances, perhaps doing something more than just
a QuerySet.

Notice that MyModel.objects.filter(...) is a manager method:
MyModel.objects is the manager and "filter" is a method on that manager.
The filter operates on the whole collection of instances and returns a
subset of them. Have a look in the Django documentation for some other
examples:

        http://www.djangoproject.com/documentation/model-api/#custom-managers

Regards,
Malcolm

> 
> If I understand correctly, it seems that a manager could more cleanly
> accomplish a lot of my recordset lookups that use a lot of arguments?
> 
> 
> > 
> 


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

Reply via email to