rf_django_misc

rf_django_misc.test.get_test_request(url='/', data=None, method='get', session_data=None, user=None)[source]

Get a test request for testing a Django view

This is helpful if you want to test a view as an isolated unit, i.e. not with the usual Django test client. This function returns a test request generated by RequestFactory, with the session and user attributes set.

Parameters:
  • url – The URL for the request
  • data – Request data
  • method – Request method
  • session_data – Session data
  • user – A user object