From c630a12e26f29145784523dd1b01ab0b3576f42c Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Wed, 1 Oct 2014 13:24:47 +0100 Subject: [PATCH] Deal with lazy strings in serializer reprs --- rest_framework/utils/representation.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rest_framework/utils/representation.py b/rest_framework/utils/representation.py index e64fdd223..180b51f8d 100644 --- a/rest_framework/utils/representation.py +++ b/rest_framework/utils/representation.py @@ -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'