Opened 10 years ago

Closed 10 years ago

#6743 closed (invalid)

LogEntry in admin doesn't support unicode

Reported by: anonymous Owned by: nobody
Component: contrib.admin Version: master
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



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' %
    class Admin:
        list_display = ('name', 'slug', 'moderated',)

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


Request Method: POST
Request URL:
Django Version: 0.97-pre-SVN-7209
Python Version: 2.5.1
Installed Applications:
Installed Middleware:

File "../lib/django-trunk\django\contrib\admin\views\" in _checklogin
  62.             return view_func(request, *args, **kwargs)
File "../lib/django-trunk\django\views\decorators\" in _wrapped_view_func
  44.         response = view_func(request, *args, **kwargs)
File "../lib/django-trunk\django\contrib\admin\views\" in add_stage
  266.             LogEntry.objects.log_action(, 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 Changed 10 years ago by Alex Gaynor

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