Loading django/views/debug.py +7 −0 Original line number Diff line number Diff line Loading @@ -893,6 +893,11 @@ Exception Value: {{ exception_value|force_escape }} <h2>Request information</h2> {% if request %} {% if request.user %} <h3 id="user-info">USER</h3> <p>{{ request.user }}</p> {% endif %} <h3 id="get-info">GET</h3> {% if request.GET %} <table class="req"> Loading Loading @@ -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 %} Loading docs/releases/1.10.txt +1 −1 Original line number Diff line number Diff line Loading @@ -165,7 +165,7 @@ Models Requests and Responses ^^^^^^^^^^^^^^^^^^^^^^ * ... * Added ``request.user`` to the debug view. Serialization ^^^^^^^^^^^^^ Loading tests/view_tests/tests/test_debug.py +12 −0 Original line number Diff line number Diff line Loading @@ -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 """ Loading Loading @@ -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() Loading @@ -263,6 +269,8 @@ class ExceptionReporterTests(SimpleTestCase): self.assertIn('<pre class="exception_value">Can't find my keys</pre>', html) self.assertIn('<th>Request Method:</th>', html) self.assertIn('<th>Request URL:</th>', html) self.assertIn('<h3 id="user-info">USER</h3>', html) self.assertIn('<p>jacob</p>', html) self.assertIn('<th>Exception Type:</th>', html) self.assertIn('<th>Exception Value:</th>', html) self.assertIn('<h2>Traceback ', html) Loading @@ -281,6 +289,7 @@ class ExceptionReporterTests(SimpleTestCase): self.assertIn('<pre class="exception_value">Can't find my keys</pre>', html) self.assertNotIn('<th>Request Method:</th>', html) self.assertNotIn('<th>Request URL:</th>', html) self.assertNotIn('<h3 id="user-info">USER</h3>', html) self.assertIn('<th>Exception Type:</th>', html) self.assertIn('<th>Exception Value:</th>', html) self.assertIn('<h2>Traceback ', html) Loading Loading @@ -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() Loading @@ -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) Loading @@ -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) Loading Loading
django/views/debug.py +7 −0 Original line number Diff line number Diff line Loading @@ -893,6 +893,11 @@ Exception Value: {{ exception_value|force_escape }} <h2>Request information</h2> {% if request %} {% if request.user %} <h3 id="user-info">USER</h3> <p>{{ request.user }}</p> {% endif %} <h3 id="get-info">GET</h3> {% if request.GET %} <table class="req"> Loading Loading @@ -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 %} Loading
docs/releases/1.10.txt +1 −1 Original line number Diff line number Diff line Loading @@ -165,7 +165,7 @@ Models Requests and Responses ^^^^^^^^^^^^^^^^^^^^^^ * ... * Added ``request.user`` to the debug view. Serialization ^^^^^^^^^^^^^ Loading
tests/view_tests/tests/test_debug.py +12 −0 Original line number Diff line number Diff line Loading @@ -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 """ Loading Loading @@ -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() Loading @@ -263,6 +269,8 @@ class ExceptionReporterTests(SimpleTestCase): self.assertIn('<pre class="exception_value">Can't find my keys</pre>', html) self.assertIn('<th>Request Method:</th>', html) self.assertIn('<th>Request URL:</th>', html) self.assertIn('<h3 id="user-info">USER</h3>', html) self.assertIn('<p>jacob</p>', html) self.assertIn('<th>Exception Type:</th>', html) self.assertIn('<th>Exception Value:</th>', html) self.assertIn('<h2>Traceback ', html) Loading @@ -281,6 +289,7 @@ class ExceptionReporterTests(SimpleTestCase): self.assertIn('<pre class="exception_value">Can't find my keys</pre>', html) self.assertNotIn('<th>Request Method:</th>', html) self.assertNotIn('<th>Request URL:</th>', html) self.assertNotIn('<h3 id="user-info">USER</h3>', html) self.assertIn('<th>Exception Type:</th>', html) self.assertIn('<th>Exception Value:</th>', html) self.assertIn('<h2>Traceback ', html) Loading Loading @@ -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() Loading @@ -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) Loading @@ -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) Loading