1
1
mirror of https://github.com/encode/django-rest-framework.git synced 2025-06-03 13:13:09 +03:00

Merge pull request from phalt/force-auth-docs

Add import example for force_authenticate in testing
This commit is contained in:
José Padilla 2015-02-18 12:20:09 -04:00
commit 4f1506c77e

View File

@ -65,6 +65,8 @@ When testing views directly using a request factory, it's often convenient to be
To forcibly authenticate a request, use the `force_authenticate()` method. To forcibly authenticate a request, use the `force_authenticate()` method.
from rest_framework.tests import force_authenticate
factory = APIRequestFactory() factory = APIRequestFactory()
user = User.objects.get(username='olivia') user = User.objects.get(username='olivia')
view = AccountDetail.as_view() view = AccountDetail.as_view()