#22817: Missing custom methods on EmptyQuerySet
-------------------------------+--------------------------------------
Reporter: benjaoming | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.6
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Comment (by benjaoming):
Replying to [comment:2 akaariai]:
> I'm probably missing some piece here - why doesn't using .none() work in
1.7? This should return a QuerySet that doesn't hit the database when
executed.
I want to be able to do:
`MyModel.objects.all().none().my_custom_manager_method()`
Now, as I understand it, that would raise AttributeError because it goes
through EmptyManager in Django 1.7 and 1.6, the case of doing
`AnonymousUser().groups.value_list('name')` is similar.
> (The example above doesn't work, first, `__init__` can't return
anything, second it would return direct QuerySet without any custom
methods which by my understanding isn't the wanted behaviour)
Sorry, yes :) So maybe this would work...
{{{
# Backwards compatible...
class EmptyQuerySet(QuerySet):
def __init__(self, *args, **kwargs):
kwargs['is_empty'] = True
QuerySet(*args, **kwargs)
}}}
It's just a conceptual picture, so if you can review the idea and indicate
if you see it happening, I'd like to work on it to fix these issues that I
otherwise don't know how to work around (for instance, I'm not managing
MPTT which is affected and affects django-wiki back).
Another fix could be if EmptyManager magically proxied all methods of the
non-empty Manager instance and just returned `self`.
--
Ticket URL: <https://code.djangoproject.com/ticket/22817#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" 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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/068.892825403f7398f375d51da11e0308e8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.