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.