{{{
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
class UserAdmin(BaseUserAdmin):
readonly_fields = ['username', 'password']
admin.site.register(User, UserAdmin)
}}}
{{{
class UserChangeForm(forms.ModelForm):
# ...
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['password'].help_text =
self.fields['password'].help_text.format('../password/')
# ...
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/29270>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by Malte Gerth):
This should fix the issue for now:
{{{
class UserChangeForm(forms.ModelForm):
# ...
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if 'password' in self.fields.keys():
self.fields['password'].help_text =
self.fields['password'].help_text.format('../password/')
# ...
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/29270#comment:1>
* stage: Unreviewed => Accepted
Comment:
`.keys()` isn't needed, otherwise the fix looks reasonable. A test goes in
`tests/auth_tests/test_forms.py` -- can you offer a pull request?
--
Ticket URL: <https://code.djangoproject.com/ticket/29270#comment:2>
* status: new => assigned
* owner: nobody => Malte Gerth
* easy: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/29270#comment:3>
Comment (by Malte Gerth):
Ok, I tried to make a pull request
https://github.com/django/django/pull/9833
--
Ticket URL: <https://code.djangoproject.com/ticket/29270#comment:4>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"874977d388decdd59022bf6b7f4d50caf2052155" 874977d3]:
{{{
#!CommitTicketReference repository=""
revision="874977d388decdd59022bf6b7f4d50caf2052155"
Fixed #29270 -- Fixed UserChangeForm crash if password field is excluded.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/29270#comment:5>