Fixed a staticfiles test on Windows.
Fixed #22823 (and partly #22563) - FKs from unmigrated apps breaking state.

Thanks to bendavis78 for the test and diagnostic work.
Fix test breakage from previous state fix
Fixed #22349 -- Added a note clarifying `RawQuerySet` has no `__len__`.

Thanks cdestigter for the report.
Fixed #16087 -- Added ResolverMatch instance to test client response.

Thanks mrmachine for the suggestion.
Fixed #6327 -- Added has_module_permission method to BaseModelAdmin

Thanks chrj for the suggestion.
Fixed #7599 -- Added get_user_permissions to ModelBackend.

Thanks to @gdub for the report and intial patch and
@charettes and @timgraham for the review.
Fixed #22477 -- Removed contrib middleware from the global settings defaults.

Also added a compatibility check for changed middleware defaults.

Forwardport of d94de802d3 from stable/1.7.x
Fixed #22771 -- Fixed test.Client.logout when using custom auth backend.
Added django.utils.six.buffer_types

and used it in the Oracle SchemaEditor. Refs #22715.
Fixed #22816 -- Corrected Oracle feature flag and fixed introspection test
Fixed #22440 -- Updated ConditionalGetMiddleware to comply with RFC 2616.
Fixed #19973 -- Replaced optparse by argparse in management commands

Thanks Tim Graham for the review.
Documented optparse to argparse changes for management commands
Converted test management command to argparse

Keeping backwards compatibility with test_runner.option_list is
tricky and would imply transforming an optparse.Option to an
argparse.Action. I choose to introduce a backwards incompatible
change because it only affects testing, not runtime behavior.
Converted remaining management commands to argparse
Fixed #22826 -- Improved internal usage of Query.setup_joins.
Removed unnecessary attribute assigment to SQLCompiler.
Improved code style of Query.table_alias() usage.
Fixed several flake8 errors