Skip to content

Instantly share code, notes, and snippets.

@ivermac
Last active March 21, 2019 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivermac/afb40a586343492cd6c6e90aa2431d5c to your computer and use it in GitHub Desktop.
Save ivermac/afb40a586343492cd6c6e90aa2431d5c to your computer and use it in GitHub Desktop.
Create django request object for testing

The following is a life-saver if you test request objects in django frequently and you don't necessarily need to hit a specific endpoint

from django.test import RequestFactory
request_factory = RequestFactory()
request = request_factory.get('/path', data={'name': u'test'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment