We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
request.user
1 parent 04134ae commit 11db342Copy full SHA for 11db342
docs/helpers.rst
@@ -130,8 +130,13 @@ Example
130
131
from myapp.views import my_view
132
133
- def test_details(rf):
+ def test_details(rf, admin):
134
request = rf.get('/customer/details')
135
+ # Remember that when using RequestFactory, the request does not pass
136
+ # through middleware. If your view expects fields such as request.user
137
+ # to be set, you need to set them explicitly.
138
+ # The following line sets request.user to an admin user.
139
+ request.user = admin
140
response = my_view(request)
141
assert response.status_code == 200
142
0 commit comments