RequestFactory versus TestClient
You may have noticed something funny about the last test: we made a request using the
RequestFactory instance, passing it a path that does not exist in
urls.py yet. Why did we have to do that?
Recall that a Django view is simply any function that accepts a request and returns a response.
RequestFactory creates a bare-bones
WSGIRequest for the first argument of a view without actually going through the Django framework (URL routing, middleware, and so on). We provide the first argument (path as a keyword) simply because you can't have a
WSGIRequest without a path. The actual argument is irrelevant, unless you're using it in the course of your view logic (meaning both
/solos/foo/ would have let the test ...