зеркало из https://github.com/mozilla/commonware.git
Add compatibility with user model without username field
This commit is contained in:
Родитель
b5544185b2
Коммит
151e42d4e0
|
@ -24,5 +24,6 @@ class ThreadRequestMiddleware(object):
|
|||
_local.remote_addr = request.META.get('REMOTE_ADDR', '')
|
||||
name = '<anon>'
|
||||
if hasattr(request, 'user') and request.user.is_authenticated():
|
||||
name = encoding.smart_str(request.user.username)
|
||||
field = getattr(request.user, 'USERNAME_FIELD', 'username')
|
||||
name = encoding.smart_str(getattr(request.user, field, ''))
|
||||
_local.username = name
|
||||
|
|
Загрузка…
Ссылка в новой задаче