mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-23 15:54:16 +03:00
Deal with lazy strings in serializer reprs
This commit is contained in:
parent
381771731f
commit
c630a12e26
|
@ -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'
|
||||
|
|
Loading…
Reference in New Issue
Block a user