Ticket #5783: auth_user_url.diff

File auth_user_url.diff, 1.1 KB (added by wnielson, 8 years ago)
  • conf/global_settings.py

     
    332332
    333333LOGIN_REDIRECT_URL = '/accounts/profile/'
    334334
     335AUTH_USERS_URL = '/users/%(username)s/'
     336
    335337###########
    336338# TESTING #
    337339###########
  • contrib/auth/models.py

     
    149149        return self.username
    150150
    151151    def get_absolute_url(self):
    152         return "/users/%s/" % urllib.quote(smart_str(self.username))
     152        from django.conf import settings
     153        import re
     154        url, url_dict = settings.AUTH_USERS_URL, dict()
     155        for attr in re.findall(r'%\(([\w_]+)\)s', url):
     156            url_dict[attr] = getattr(self, attr)
     157        url = url % url_dict
     158        return urllib.quote(smart_str(url))
    153159
    154160    def is_anonymous(self):
    155161        "Always returns False. This is a way of comparing User objects to anonymous users."
Back to Top