Managers operate on your model, so their methods usually call sgl
queries on a model's database.

As an example, assume a blog app with a Post model which, among other
things has a BooleanField called 'draft'.

You could then write a custom manager called PublishedManager that
subclasses the default manager and overrides the default get_queryset
method, so that a .filter(draft=False) is added to every query.

Add it to your Post model by setting it as the 'published' attribute
and then you could use Post.published.all() to get just the posts with
draft=False.


Cheers,
AT

On 7/22/11, Shawn Milochik <sh...@milochik.com> wrote:
> On 07/22/2011 10:30 AM, Eyad Al-Sibai wrote:
>> Hi!
>>
>> I still do not get the meaning of Manager or Custom Manager in
>> Django... I am confused!
>>
>
> If you've used the '.objects' attribute of a model you've used a manager.
>
> A custom manager would be a subclass of the standard manager. You can
> then alter/replace things like all(), filter(), and get(), and add your
> own methods.
>
>
> --
> 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.
>
>

-- 
Sent from my mobile device

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