admin: replace unicode by force_text (#46563)
This commit is contained in:
parent
3498d9ffac
commit
547fe4abb5
|
@ -4,6 +4,7 @@ import django.contrib.admin as admin
|
|||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.utils.html import escape
|
||||
from django.db import models
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.core.urlresolvers import reverse, NoReverseMatch
|
||||
|
||||
|
@ -35,9 +36,9 @@ class ModelAdminFormatter(Formatter):
|
|||
if self.filter_link:
|
||||
content_type = ContentType.objects.get_for_model(value.__class__)
|
||||
res = u'<a href="?objectdata__content_type={0}&objectdata__object_id={1}">{2}</a>'.format(
|
||||
content_type.id, value.pk, escape(unicode(value)))
|
||||
content_type.id, value.pk, escape(force_text(value)))
|
||||
else:
|
||||
res = escape(unicode(value))
|
||||
res = escape(force_text(value))
|
||||
if self.object_link:
|
||||
res += self.build_object_link(value)
|
||||
return res
|
||||
|
@ -119,7 +120,7 @@ class JournalAdmin(admin.ModelAdmin):
|
|||
|
||||
def object_filter_link(self, objectdata):
|
||||
if objectdata.content_object is not None:
|
||||
caption = unicode(objectdata.content_object)
|
||||
caption = force_text(objectdata.content_object)
|
||||
else:
|
||||
caption = _(u'<deleted {content_type} {object_id}>').format(
|
||||
content_type=objectdata.content_type,
|
||||
|
|
Loading…
Reference in New Issue