Should __unicode__ be used when returning purely numerical values?
|Reported by:||sampablokuper||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
http://docs.djangoproject.com/en/dev/intro/tutorial01/#playing-with-the-api says, "It's important to add __unicode__() methods to your models, not only for your own sanity when dealing with the interactive prompt, but also because objects' representations are used throughout Django's automatically-generated admin."
However, if I have a class like the following:
class C19Year(models.Model): value = IntegerRangeField(min_value=1800, max_value=1899) def __unicode__(self): return self.value
(where IntegerRangeField is as given here), I receive the following TemplateSyntaxError in the admin:
Caught an exception while rendering: coercing to Unicode: need string or buffer, int found
So, evidently the manual ought to explain that __unicode__ shouldn't be used when returning purely numerical values, or that such values ought to be converted to strings. (Of these two solutions, I'm not sure which is best.)