﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
13945	[Enhancement] Better diagnostics when view returns rendered SafeUnicode	JonathanHayward	nobody	"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/"		closed	Uncategorized	1.2		wontfix			Unreviewed	0	0	0	0	0	0
