Opened 17 years ago

Closed 17 years ago

#6743 closed (invalid)

LogEntry in admin doesn't support unicode

Reported by: anonymous Owned by: nobody
Component: contrib.admin Version: dev
Severity: Keywords: admin unicode logentry
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi!

I've just installed fresh Django instance from SVN.

Model is pretty simple:

class City(models.Model):
    name = models.CharField(_('City'), max_length=64, )
    slug = models.SlugField(_('Slug'), prepopulate_from =('name',), )
    moderated = models.NullBooleanField('Approved by moderator',)

    def __str__(self):
        return '%s' % self.name
    
    class Admin:
        list_display = ('name', 'slug', 'moderated',)

While adding this object with name in Russian, I meet an error:

Environment:

Request Method: POST
Request URL: http://127.0.0.1:8000/admin/core/city/add/
Django Version: 0.97-pre-SVN-7209
Python Version: 2.5.1
Installed Applications:
['django.contrib.auth',
 'django.contrib.admin',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'aru.core']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.doc.XViewMiddleware')


Traceback:
File "../lib/django-trunk\django\contrib\admin\views\decorators.py" in _checklogin
  62.             return view_func(request, *args, **kwargs)
File "../lib/django-trunk\django\views\decorators\cache.py" in _wrapped_view_func
  44.         response = view_func(request, *args, **kwargs)
File "../lib/django-trunk\django\contrib\admin\views\main.py" in add_stage
  266.             LogEntry.objects.log_action(request.user.id, ContentType.objects.get_for_model(model).id, pk_value, force_unicode(new_object), ADDITION)



Exception Type: UnicodeEncodeError at /admin/core/city/add/
Exception Value: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)

But the object was successfully added - only Log Entry doesn't appear.

Change History (1)

comment:1 by Alex Gaynor, 17 years ago

Resolution: invalid
Status: newclosed

Your model should define a unicode method not an str method, please try changing this, for now I will close the ticket, if that doesn't fix it, feel free to reopen.

Note: See TracTickets for help on using tickets.
Back to Top