Reputation: 376
I am using active directory login authentication for my django web application. So there is no need of change password link in admin site.
I have searched lot of article, but I haven't found any thing to hide change password link. So what is the way of hiding change password link from admin?
Upvotes: 4
Views: 2860
Reputation: 4826
You don't need to override admin template.
If user.has_usable_password()
returns False
, then Django will not display change password URL for that user.
user.has_usable_password()
can be made to return False
by calling user.set_unusable_password()
.
From docs:
set_unusable_password()
Marks the user as having no password set. This isn’t the same as having a blank string for a password.
check_password()
for this user will never returnTrue
. Doesn’t save the User object.You may need this if authentication for your application takes place against an existing external source such as an LDAP directory.
has_usable_password()
Returns
False
ifset_unusable_password()
has been called for this user.
Source code for condition filter in Django base admin template:
{% if user.has_usable_password %}
<a href="{% url 'admin:password_change' %}">{% translate 'Change password' %}</a>
{% endif %}
Upvotes: 4