I'm not a big fan of TIMTOWTDI so I don't think we should have both 
`Manager.from_queryset()` and `QuerySet.as_manager()`.

The following commit moved all the logic that was on `QuerySet` to the 
`Manager` class and implemented the `from_queryset()` API:

    https://github.com/loic/django/commit/e53ce4b

The resulting API is:

    from django.db.models import Manager
    with_default_manager = Manager.from_queryset(CustomQuerySet)
    with_custom_manager = CustomManager.from_queryset(CustomQuerySet)

The following commit builds on the previous one and removes `from_queryset()` 
in favor of  `as_manager()` while keeping most of the logic on the `Manager` 
class:

    https://github.com/loic/django/commit/57bedb6

The resulting API is:

    with_default_manager = CustomQuerySet.as_manager()
    with_custom_manager = CustomQuerySet.as_manager(CustomManager)

Anssi summarized the pros and cons of each approach on 
https://github.com/django/django/pull/1328#issuecomment-21365845.

I'm not gonna try to weight in any further for one API or the other; both are 
implemented and I'll update the docs as soon as a decision is taken.

-- 
Loic

On Jul 23, 2013, at 3:17 AM, Aymeric Augustin 
<[email protected]> wrote:

> If you really want the short and sweet API, I can listen for an argument to 
> implement it as follows:
> 
> class QuerySet:
>    def as_manager(self, *args, **kwargs):
>        # imported here because this method creates a circular dependency
>        # between Manager  and QuerySet
>        from django.db.models import Manager
>        return Manager.from_queryset(self, *args, **kwargs)

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to