[1.6.x] Fixed #22429 -- Incorrect SQL when using ~Q and F

Backpatch of 5e1f4656b98816c96a1cc051224c1b699db480e0 from master.

Conflicts:
	django/db/models/sql/query.py
	tests/queries/models.py
	tests/queries/tests.py
[1.6.x] Fixed #22575 -- Fixed typo in docs/topics/class-based-views/generic-editing.txt.

Thanks adminq80 at gmail.com.

Backport of 87776859af from master
[1.6.x] Fixed #1349 -- Clarified docs on serving files from STATIC/MEDIA_URL.

Backport of fb7c347f7b from master
[1.6.x] Fixed #22585 -- Fixed typo in topics/auth/customizing.txt.

Thanks matt at mattwoodward.com for the report.
[1.6.x] Updated the messages context processor docs
[1.6.x] Fixed #22508 -- Avoided overwriting select_related.

Previously, known related objects overwrote related objects loaded
though select_related. This could cancel the effect of select_related
when it was used over more than one level.

Thanks boxm for the bug report and timo for bisecting the regression.

Conflicts:
	tests/select_related_regress/tests.py

Backport of f574220f from master
[1.6.x] Fix typo in release notes.
[1.6.x] Insert space.

Backport of 8eb51a8cf6 from master
[1.6.x] Fixed #22613 -- Added formfield_for_choice_field() to the list of methods that InlineModelAdmin supports.

Backport of 986bd41f8a from master
[1.6.x] Added 1.6.5 release note for refs #22508.

Backport of 13087020a9 from master
[1.6.x] Fixed #22619 -- Corrected description of os.path.

Thanks Collin Anderson for the report.

Backport of a1be7237ca from master
[1.6.x] Fixed typo in transactions.txt

Backport of f2a8e47cfd from master
[1.6.x] Removed an unnecessary anchor in the docs.

Backport of a06808d370 from master
[1.6.x] Dropped fix_IE_for_vary/attach.

This is a security fix. Disclosure following shortly.
[1.6.x] Added additional checks in is_safe_url to account for flexible parsing.

This is a security fix. Disclosure following shortly.
Added release notes for 1.4.13, 1.5.8, 1.6.5.
Updated version numbers for release.
Updated version numbers post-release.
[1.6.x] Minor edits to latest release notes.

Backport of 860d31ac7a from master
[1.6.x] Fixed typo in multipartparser.py

Backport of 8a9d54aa69 from master