django-model-behaviors-example
django-model-behaviors-example copied to clipboard
Add support for chained .none()
You need this to have your querysets fully identical to standard queryset behavior :) Notice there's some change in Django 1.6 that I didn't fully catch up on.
Admittedly I didn't see you were using pass_through_manager -- can you tell me if for instance objects.none().published() already works?
Btw great job, very inspirational
chaining after a call to none() doesn't work with PassthroughManager because it changes to an EmptyQuerySet so it no longer returns our custom QuerySet sub-class. Your commit doesn't necessarily resolve this since you need to wire PassthroughManager.
I think this is better solved by PassthroughManager directly. Without that, I'd focus on making a generic solution by sub-classing PassthroughManager or our base QuerySet, and return a sub-class of EmptyQuerySet that accepts arbitrary chained methods and just returns itself.
PassthroughManager is a nice idea, but I rather don't like the dependency because it's such simple code that it's easy to deal with either by copy-pasting the PassthroughManager itself or just write the QuerySet and the manager explicitly. A rather small bargain to avoid dependencies :)