diff --git a/common/djangoapps/student/models.py b/common/djangoapps/student/models.py index 6725cdf0e7c3db5f04ba37a2a3ef76875d54a9a2..9a7e521eb8968d9f5b86e4faeb0276ad7c6c1318 100644 --- a/common/djangoapps/student/models.py +++ b/common/djangoapps/student/models.py @@ -40,6 +40,7 @@ from django.utils.functional import cached_property from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_noop from django_countries.fields import CountryField +from django.utils.encoding import python_2_unicode_compatible from edx_django_utils.cache import RequestCache from edx_rest_api_client.exceptions import SlumberBaseException from eventtracking import tracker @@ -2813,6 +2814,7 @@ class RegistrationCookieConfiguration(ConfigurationModel): ) +@python_2_unicode_compatible class UserAttribute(TimeStampedModel): """ Record additional metadata about a user, stored as key/value pairs of text. @@ -2828,12 +2830,11 @@ class UserAttribute(TimeStampedModel): name = models.CharField(max_length=255, help_text=_("Name of this user attribute."), db_index=True) value = models.CharField(max_length=255, help_text=_("Value of this user attribute.")) - def __unicode__(self): - """Unicode representation of this attribute. """ - return u"[{username}] {name}: {value}".format( + def __str__(self): + return "[{username}] {name}: {value}".format( name=self.name, value=self.value, - username=self.user.username, + username=self.user.username ) @classmethod