I've noted that the generic view implementations use the private `_clone`
method when returning the queryset
attribute<https://github.com/django/django/blob/master/django/views/generic/detail.py#L72>
.
Presumably the need for that is something to do with the potential for
querysets to be cached or otherwise incorrectly stateful if this cloning
isn't performed. What's confusing me is that it's not at all obvious
*exactly* what the implications of making (or failing to make) this call
are.
Furthermore if it *is* something that's strictly required in this
circumstance then do we need to be documenting whatever behavior is being
triggered, so that developers writing their own class based views don't
make the (mistake?) of simply returning/using a queryset attribute without
having first cloned it?
For example, is the following incorrect?
class SomeBaseGenericView(View):
queryset = None
def get_queryset(self):
"""
Simply return `.queryset` by default. Subclasses may override
this behavior.
"""
return self.queryset
If so, under what set of conditions can it fail, and is it possible to unit
test for the failing behavior?
I've dug into the source, but the `_clone` method isn't documented, nor can
I find anything terribly helpful related to queryset cloning after googling
around for a while.
Many thanks,
Tom
--
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.