#4921: django.contrib.admin ignores __str__ on model instances
---------------------------------------------------------+------------------
Reporter: Ludvig Ericson <[EMAIL PROTECTED]> | Owner:
adrian
Status: closed |
Component: Admin interface
Version: SVN |
Resolution: invalid
Keywords: admin unicode listing |
Stage: Accepted
Has_patch: 0 |
Needs_docs: 0
Needs_tests: 0 |
Needs_better_patch: 0
---------------------------------------------------------+------------------
Changes (by mtredinnick):
* status: new => closed
* resolution: => invalid
Comment:
I don't see the bug here at all. Using this model
{{{
#!python
from django.db import models
from django.utils.encoding import smart_str
class T4921(models.Model):
name = models.CharField(maxlength=50)
def __str__(self):
return smart_str('foo: %s' % self.name)
class Admin:
pass
}}}
and following the instructions in comment 2, the right string is displayed
in the list view. If I change the {{{__str__}}} method to a
{{{__unicode__}}} method (and remove the smart_str() bit, obviously), the
right string is displayed, because the model's default {{{__str__}}} calls
the {{{__unicode__}} method. If I have both a {{{__str__}}} and a
{{{__unicode__}}} method defined, the {{{__str__}}} method is called, but
that's intentional: we have to call one or the other, so we pick one (and
we pick {{{__str__}}} so that it's backwards compatible).
So nothing appears to be providing the wrong result. If you provide a
{{{__str__}}} method, it is called; if you only provide a
{{{__unicode__}}} method, it is used. I'm going to close as invalid for
now. Please reopen with a concrete example like this one that demonstrates
whatever problem you are seeing if you still think there's a bug.
--
Ticket URL: <http://code.djangoproject.com/ticket/4921#comment:7>
Django Code <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
-~----------~----~----~----~------~----~------~--~---