#11819: Should __unicode__ be used when returning purely numerical values?
---------------------------+------------------------------------------------
Reporter: sampablokuper | Owner: nobody
Status: new | Milestone:
Component: Documentation | Version: 1.1
Keywords: | Stage: Unreviewed
Has_patch: 0 |
---------------------------+------------------------------------------------
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
[http://stackoverflow.com/questions/849142/how-to-limit-the-maximum-value-
of-a-numeric-field-in-a-django-model 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.)
--
Ticket URL: <http://code.djangoproject.com/ticket/11819>
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
-~----------~----~----~----~------~----~------~--~---