[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