[1.4.x] Fixed #19645 -- Added tests for TransactionMiddleware

Backpatch of f556df90be995a83b979cf875705d98521ab4dc7. Backpatching
these tests so that it will be easier to backpatch the fix for #19707.
[1.4.x] Fixed #19707 -- Reset transaction state after requests

Backpatch of a4e97cf315142e61bb4bc3ed8259b95d8586d09c.
[1.4.x] Made custom m2m fields without through easier to use

The change in f105fbe52b21da206bfbaedf0e92326667d7b2d4 made through=None
m2m fields fail in cases where they worked before. It isn't possible to
create such fields using public APIs. The fix is trivial, so it seems
worth fixing this for custom m2m field users.

This is not a backport from master. Master has gotten enough other
changes to related fields internal API that this fix alone isn't enough
to do any good.
Fixed WSGIPythonPath instruction in deployment docs

Partial backport of 3abf6105b6 from master. Refs #19042.