what is query.clone(), queryset.clone() for in django?
django, django-queryset
Solution
There are two main reasons for `clone()`:
It allows chaining. When you chain querysets together (for example, multiple `filter()` calls), you want a fresh copy of the queryset each time that you can modify.
It allows you to avoid stale cache results. Since querysets cache their results when they are evaluated, if you want to make sure you hit the database again you need to clone the queryset.
If you know what you're doing you could use it, but note that it isn't a public API. In this interesting Django developers thread the developers talk about whether or not `clone()` should be public. They decide against it, in part because:
The biggest problem with public `.clone()` method is that the private `._clone()` doesn't do just cloning. There are some cases where cloning also changes how the QuerySet behaves.
Problem
I see clone() being used extensively in django code ``` queryset.query.clone() queryset.clone() ``` What is it for and should I mimic the behavior in my queryset or manager methods?