How to add session and messages in Django RequestFactory

If you are using RequestFactory while testing your Django views, you will probably need session data especially when you are testing Login view or the messages framework to test success/failure messages.

Here’s how you can do it.

Leave a like if you find this useful.