Skip to content

Commit 4f1506c

Browse files
committed
Merge pull request #2562 from phalt/force-auth-docs
Add import example for force_authenticate in testing
2 parents 3a71b6c + d9c6528 commit 4f1506c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

docs/api-guide/testing.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ When testing views directly using a request factory, it's often convenient to be
6565

6666
To forcibly authenticate a request, use the `force_authenticate()` method.
6767

68+
from rest_framework.tests import force_authenticate
69+
6870
factory = APIRequestFactory()
6971
user = User.objects.get(username='olivia')
7072
view = AccountDetail.as_view()

0 commit comments

Comments
 (0)