Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't assume USERNAME_FIELD == 'user' in UserAdmin. #427

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions django/contrib/auth/admin.py
Expand Up @@ -106,9 +106,10 @@ def add_view(self, request, form_url='', extra_context=None):
raise PermissionDenied
if extra_context is None:
extra_context = {}
username_field = self.model._meta.get_field(getattr(self.model, 'USERNAME_FIELD', 'username'))
defaults = {
'auto_populated_fields': (),
'username_help_text': self.model._meta.get_field('username').help_text,
'username_help_text': username_field.help_text,
}
extra_context.update(defaults)
return super(UserAdmin, self).add_view(request, form_url,
Expand All @@ -133,7 +134,7 @@ def user_change_password(self, request, id, form_url=''):
adminForm = admin.helpers.AdminForm(form, fieldsets, {})

context = {
'title': _('Change password: %s') % escape(user.username),
'title': _('Change password: %s') % escape(str(user)),
'adminForm': adminForm,
'form_url': form_url,
'form': form,
Expand Down