Deal with lazy strings in serializer reprs

This commit is contained in:
Tom Christie 2014-10-01 13:24:47 +01:00
parent 381771731f
commit c630a12e26

View File

@ -3,6 +3,8 @@ Helper functions for creating user-friendly representations
of serializer classes and serializer fields.
"""
from django.db import models
from django.utils.functional import Promise
from rest_framework.compat import force_text
import re
@ -19,6 +21,9 @@ def smart_repr(value):
if isinstance(value, models.Manager):
return manager_repr(value)
if isinstance(value, Promise) and value._delegate_text:
value = force_text(value)
value = repr(value)
# Representations like u'help text'