Buglet in admin interface 'delete' view?

2 views
Skip to first unread message

Pryankster

unread,
Aug 12, 2008, 2:31:21 AM8/12/08
to Django users
When trying to delete a model, the admin interface gives me a list of
related objects which will also be deleted. If the return value from
the __unicode__() method of those objects contains naughty
characters (in this case, it was just a single-quote) the naughty-
characters get escaped twice, thus the single-quote shows up as
"'". I.e., and object named "men's chorus" is printed (in the
delete screen) as "men's chorus"

I'm using 8252 from svn.

-- pryankster

Julien Phalip

unread,
Aug 12, 2008, 3:34:47 AM8/12/08
to Django users
Could you show the code of your __unicode__ method?

Pryankster

unread,
Aug 12, 2008, 5:29:22 AM8/12/08
to Django users
it's pretty simple:

name = models.CharField(max_length=100)

def __unicode__(self):
return self.name

Note that the name appears correct in 'list' pages and in the edit
page for the item itself, it's just in the delete item for the
'parent' item where the display is messed up (which makes me think
double-escaping)

-- pryankster

Julien Phalip

unread,
Aug 12, 2008, 9:53:06 AM8/12/08
to Django users
Yes you're right, the items are escaped twice, once in
admin.util.get_deleted_objects, and then in the unordered_list filter.
I've created a ticket and posted a patch. Could you try the patch and
see if it fixes the problem?

http://code.djangoproject.com/ticket/8258

Pryankster

unread,
Aug 12, 2008, 1:15:52 PM8/12/08
to Django users
Yep. that did the trick -- I tried all kinds of nasty characters
<,>&#'" in the field values and it did the right thing.

Thanks!
-- pryankster
Reply all
Reply to author
Forward
0 new messages