﻿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
3996	[unicode][patch] NodeList and smart_str prefer __str__ to __unicode__	Ivan Sagalaev <Maniac@…>	Malcolm Tredinnick	"This is tricky one :-)

When a template is rendered its NodeList does somethig like this:

{{{
''.join([smart_str(node, settings.DEFAULT_CHARSET) for node in nodes])
}}}

The smart_str converts any object to a str. Now, if an object is a model instance and that only !__unicode!__ method, smart_str doesn't use it at all and uses instead default Model.!__str!__. This leads to simple things like this:

{{{
{{ obj }}
}}}

to give out ""ModelName object"" instead of meaningful things.

I'm not sure where to fix it:

  * change smart_str to look for !__unicode!__ and call it explicitly before str()
  * change NodeList to do {{{u''.join(...).decode(settings.DEFAULT_CHARSET)}}}
  * (not a fix but masking) change Model.!__str!__ to look into !__unicode!__

I actually prefer to do all these items, they all seem logical. Except may be the first one since I don't understand completely the semantics of smart_str."		closed	Uncategorized	other branch		fixed	unicode	Maniac@…	Accepted	0	0	0	0	0	0
