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
Restored command error behavior when called from command line

Refs #19973.
Fixed #7762 -- Hidden full script name in command error output
Complemented dwithin docs about using geographic geometries

Refs #22830. Thanks django@gfairchild.com for the suggestion.
Merge pull request #2806 from jorgecarleitao/issue22826

Fixed #22826 -- Improved internal usage of Query.setup_joins.
Fixed #22842