Code

Opened 6 years ago

Closed 6 years ago

#6016 closed (invalid)

Admin crash when deleting an object

Reported by: aribao@… Owned by:
Component: contrib.admin Version: master
Severity: Keywords: unicode delete
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by gwilson)

I get this error:

DjangoUnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 0: ordinal not in range(128). You passed in DjangoUnicodeDecodeError('ascii', '\xc2\xbfProbando una pregunta? -> ', 0, 1, 'ordinal not in range(128)') (<class 'django.utils.encoding.DjangoUnicodeDecodeError'>)

when I try to delete an object from the admin zone. The character ¿ breaks it.

More info. Model:

class Encuesta( models.Model ):
    ...
    pregunta = models.CharField( max_length=255 )

    def __unicode__( self ):
        return self.pregunta
   ...

Thanks

Attachments (0)

Change History (8)

comment:1 Changed 6 years ago by gwilson

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

fixed description formatting.

comment:2 Changed 6 years ago by raphael

  • Owner changed from nobody to raphael
  • Status changed from new to assigned

comment:3 Changed 6 years ago by raphael

I can't reproduce it so far in admin.

The only way I found to get similar errors is to do sth like :

obj.pregunta = '\xc2\xbfProbando una pregunta? -> '
obj.save()
unicode(obj)

But aren't we supposed to do :
obj.pregunta = u'\xc2\xbfProbando una pregunta? -> ' # add u

or to get the same output :
obj.pregunta = u'\xbfProbando una pregunta? -> '

My poor knowledge in Django unicode internals don't allow me to go further :(

comment:4 Changed 6 years ago by raphael

  • Owner raphael deleted
  • Status changed from assigned to new

comment:5 Changed 6 years ago by raphael

  • Resolution set to worksforme
  • Status changed from new to closed

comment:6 Changed 6 years ago by raphael

  • Resolution worksforme deleted
  • Status changed from closed to reopened

comment:7 Changed 6 years ago by anonymous

these one helped me:

def unicode(self):

return u'%s' % self.user

comment:8 Changed 6 years ago by PJCrosier

  • Resolution set to invalid
  • Status changed from reopened to closed

Comment 7 seems sane to me, please re-open / slap me if I'm wrong.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.