Ticket #10858: auth_user_model_unicode.diff

File auth_user_model_unicode.diff, 1.2 KB (added by Paul McLanahan, 10 years ago)

Patch

  • django/contrib/auth/models.py

     
    22import urllib
    33
    44from django.contrib import auth
     5from django.conf import settings
    56from django.core.exceptions import ImproperlyConfigured
    67from django.db import models
    78from django.db.models.manager import EmptyManager
     
    145146        verbose_name_plural = _('users')
    146147
    147148    def __unicode__(self):
    148         return self.username
     149        fmt = getattr(settings, 'AUTH_USER_STR_FORMATTER', None)
     150        if fmt is not None:
     151            return fmt(self)
     152        else:
     153            return self.username
    149154
    150155    def get_absolute_url(self):
    151156        return "/users/%s/" % urllib.quote(smart_str(self.username))
     
    276281        SiteProfileNotAvailable if this site does not allow profiles.
    277282        """
    278283        if not hasattr(self, '_profile_cache'):
    279             from django.conf import settings
    280284            if not getattr(settings, 'AUTH_PROFILE_MODULE', False):
    281285                raise SiteProfileNotAvailable
    282286            try:
Back to Top