diff --git a/django/views/debug.py b/django/views/debug.py
index 1aeb05f7b0..977b1c6591 100644
--- a/django/views/debug.py
+++ b/django/views/debug.py
@@ -893,6 +893,11 @@ Exception Value: {{ exception_value|force_escape }}
Request information
{% if request %}
+ {% if request.user %}
+ USER
+ {{ request.user }}
+ {% endif %}
+
GET
{% if request.GET %}
@@ -1088,6 +1093,8 @@ File "{{ frame.filename }}" in {{ frame.function }}
{% if exception_type %}Exception Type: {{ exception_type }}{% if request %} at {{ request.path_info }}{% endif %}
{% if exception_value %}Exception Value: {{ exception_value }}{% endif %}{% endif %}{% endif %}
{% if request %}Request information:
+{% if request.user %}USER: {{ request.user }}{% endif %}
+
GET:{% for k, v in request.GET.items %}
{{ k }} = {{ v|stringformat:"r" }}{% empty %} No GET data{% endfor %}
diff --git a/docs/releases/1.10.txt b/docs/releases/1.10.txt
index 183699505a..1eada416f6 100644
--- a/docs/releases/1.10.txt
+++ b/docs/releases/1.10.txt
@@ -165,7 +165,7 @@ Models
Requests and Responses
^^^^^^^^^^^^^^^^^^^^^^
-* ...
+* Added ``request.user`` to the debug view.
Serialization
^^^^^^^^^^^^^
diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py
index b4e7f9c7fa..590d75264f 100644
--- a/tests/view_tests/tests/test_debug.py
+++ b/tests/view_tests/tests/test_debug.py
@@ -36,6 +36,11 @@ if six.PY3:
from .py3_test_debug import Py3ExceptionReporterTests # NOQA
+class User(object):
+ def __str__(self):
+ return 'jacob'
+
+
class CallableSettingWrapperTests(SimpleTestCase):
""" Unittests for CallableSettingWrapper
"""
@@ -254,6 +259,7 @@ class ExceptionReporterTests(SimpleTestCase):
"A simple exception report can be generated"
try:
request = self.rf.get('/test_view/')
+ request.user = User()
raise ValueError("Can't find my keys")
except ValueError:
exc_type, exc_value, tb = sys.exc_info()
@@ -263,6 +269,8 @@ class ExceptionReporterTests(SimpleTestCase):
self.assertIn('Can't find my keys
', html)
self.assertIn('Request Method: | ', html)
self.assertIn('Request URL: | ', html)
+ self.assertIn('USER
', html)
+ self.assertIn('jacob
', html)
self.assertIn('Exception Type: | ', html)
self.assertIn('Exception Value: | ', html)
self.assertIn('Traceback ', html)
@@ -281,6 +289,7 @@ class ExceptionReporterTests(SimpleTestCase):
self.assertIn('Can't find my keys
', html)
self.assertNotIn('Request Method: | ', html)
self.assertNotIn('Request URL: | ', html)
+ self.assertNotIn('USER
', html)
self.assertIn('Exception Type: | ', html)
self.assertIn('Exception Value: | ', html)
self.assertIn('Traceback ', html)
@@ -455,6 +464,7 @@ class PlainTextReportTests(SimpleTestCase):
"A simple exception report can be generated"
try:
request = self.rf.get('/test_view/')
+ request.user = User()
raise ValueError("Can't find my keys")
except ValueError:
exc_type, exc_value, tb = sys.exc_info()
@@ -464,6 +474,7 @@ class PlainTextReportTests(SimpleTestCase):
self.assertIn("Can't find my keys", text)
self.assertIn('Request Method:', text)
self.assertIn('Request URL:', text)
+ self.assertIn('USER: jacob', text)
self.assertIn('Exception Type:', text)
self.assertIn('Exception Value:', text)
self.assertIn('Traceback:', text)
@@ -482,6 +493,7 @@ class PlainTextReportTests(SimpleTestCase):
self.assertIn("Can't find my keys", text)
self.assertNotIn('Request Method:', text)
self.assertNotIn('Request URL:', text)
+ self.assertNotIn('USER:', text)
self.assertIn('Exception Type:', text)
self.assertIn('Exception Value:', text)
self.assertIn('Traceback:', text)