Am 03.10.2011 um 20:01 schrieb Javier Guerra Giraldez:

> On Fri, Sep 30, 2011 at 4:37 PM, Johannes Dollinger
> <[email protected]> wrote:
>> The aim of this proposal is to reuse Q objects for models that are related 
>> through FK or M2M fields.
> 
> i really want to have this feature!  so i went and did a quick
> implementation and created ticket #16979[1]
> 
> [1]:https://code.djangoproject.com/ticket/16979
> 
> really untested, but a variation that doesn't modify core seems to
> work well (but the API is far too ugly to share)

Thanks for starting this!
Why did you chose a staticmethod instead of an instancemethod?
While I'm not sold on the method name (perhaps prefix() or shift() or even 
__rshift__() would be clearer), I believe the ability to modify Q objects 
outside of filter()-Expressions is important.
Just like &, |, and ~, adding a prefix is an operation on Q objects. And the 
API should provide a way to manipulate them fully outside of QuerySets.

As an afterthought: The cleanest solution would probably be an implementation 
in Q.__init__.
The .push() method would then be unnecessary, as you could write Q(foo=Q(...)) 
instead of Q(..).push('foo').
And .filter()/.exclude() would just work, as they simply pass their arguments 
through to Q.__init__.

__
Johannes

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" 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-developers?hl=en.

Reply via email to