On Jul 22, 2013, at 4:38 PM, Chris Wilson <ch...@aptivate.org> wrote:

> I think that's very true. How about this?
> 
>>      class MyQuerySet(models.QuerySet):
>>          def published(self):
>>              return self.filter(published_date__lte=now())
>> 
>>      class MyModel(models.Model):
>>          published_date = models.DateTimeField()
>> 
>>          objects = CustomManager(MyQuerySet)

That was my original proposal; the first 20 comments on the ticket and one 
nearly complete implementation are based on this idea.

That approach has the downside of requiring the use of `__getattr__` or 
`__getattribute__` which is IMO much more of a hack than a class factory, 
especially with backward compatibility in mind.

On Jul 22, 2013, at 4:32 PM, Aymeric Augustin 
<aymeric.augus...@polytechnique.org> wrote:

> The idea of `QuerySet .as_manager()` sounded sane to me at first—especially 
> in the light of the failure of various other attempts—but it creates a 
> circular dependency between `Manager` and `QuerySet`. Creating the `Manager` 
> class now requires the `QuerySet` class, and `QuerySet` needs a reference to 
> `Manager` for `as_manager()`.

We are trying to blur the line between `QuerySet` and `Manager`, or to quote 
you, tackle the "Great QuerySet - Manager Unification". I see this circular 
dependency as an implementation detail due to the fact that we have to deal 
with backward compatibility and we can't just ditch one class or the other.

That said, I willing to try moving some of the code back onto `Manager`.

-- 
Loic

-- 
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 django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
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