I've used django.test.Client for several large projects over the years. Recently, I got stuck because I couldn't get session management to work in my tests. Judging from the number of StackOverflow, etc, posts on this topic, this is a common issue. Eventually I found https://stackoverflow.com/questions/25132621/ which put me onto using RequestFactory instead of the Test Client. I'm sure I'd seen RequestFactory mentioned before, but never explored it.
I think RequestFactory should be emphasized more in https://docs.djangoproject.com/en/3.1/topics/testing/tools/. Right now, the only mention is buried deep down on the page in a "See also" box which links to the "Advanced testing topics". Labeling it as an "advanced" topic is misleading. May I suggest that it should be at least briefly covered in the introductory section. There's already a couple of paragraphs contrasting django.test.client to Selenium. It would be good to say something like:
A lower-level alternative to the test client is RequestFactory, which lets you bypass the routing and middleware layers. Use RequestFactory to write unit tests of individual view functions and methods. Use the test client to write integration tests of how your views work in the context of your full application. Use Selenium to test rendered HTML and the behavior of Web pages, namely JavaScript functionality.
I'd be happy to write up an improved doc if you think this is a reasonable way to go.
Hey Roy, OK — very happy to look at a suggestion here. Thanks.