﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
36385	Simplify implementation of filtering in QuerySet.	Nick Pope	Nick Pope	"Some of the code for filtering QuerySet is overly complex which makes it hard to follow:

- Methods that are nearly identical, e.g. `QuerySet._clone()` vs `QuerySet._chain()` and `Query.clone()` vs `Query.chain()`
  - These used to do more, but now are not significantly different such that they're worth keeping separate.
- Private API like `Queryset.complex_filter()` which exists for a specific case but can be handled using public APIs
- Flags such as `_defer_next_filter` and `_sticky_filter` that affect the ''next'' call to `QuerySet.filter()`
- Passing around deconstructed pieces instead of building a `Q()` object as early as possible
- Not using the `klass` argument to `Query.chain()` and altering `__class__` manually

We should be able to simplify this, removing a number of flag attributes and methods in the process.
"	Cleanup/optimization	assigned	Database layer (models, ORM)	dev	Normal			Simon Charette	Accepted	1	1	0	1	0	0
