#13945: [Enhancement] Better diagnostics when view returns rendered SafeUnicode
-----------------------------+----------------------------------------------
Reporter: JonathanHayward | Owner: nobody
Status: new | Milestone:
Component: Uncategorized | Version: 1.2
Keywords: | Stage: Unreviewed
Has_patch: 0 |
-----------------------------+----------------------------------------------
I made the mistake of making a view return SafeUnicode returned by a
renderer, instead of an HttpResponse. The error message does not make it
clear to a learner that a string-like object has been returned where an
HttpResponse is needed:
{{{
Traceback (most recent call last):
File "/usr/local/lib/python2.6/site-
packages/django/core/servers/basehttp.py", line 280, in run
self.result = application(self.environ, self.start_response)
File "/usr/local/lib/python2.6/site-
packages/django/core/servers/basehttp.py", line 674, in __call__
return self.application(environ, start_response)
File "/usr/local/lib/python2.6/site-
packages/django/core/handlers/wsgi.py", line 245, in __call__
response = middleware_method(request, response)
File "/usr/local/lib/python2.6/site-
packages/django/contrib/sessions/middleware.py", line 26, in
process_response
patch_vary_headers(response, ('Cookie',))
File "/usr/local/lib/python2.6/site-packages/django/utils/cache.py",
line 127, in patch_vary_headers
if response.has_header('Vary'):
AttributeError: 'SafeUnicode' object has no attribute 'has_header'
}}}
This is not quite as informative as a usual Django error page. Perhaps
error handling could give friendlier diagnostics if a view returns
something string-like when it should return an HttpResponse?
Jonathan
http://JonathansCorner.com/
--
Ticket URL: <http://code.djangoproject.com/ticket/13945>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.