Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

2K
Visualizações
Django: admin interface: how to change user password

In Django:

I have created a super user and can view all the users

I have also implemented forgot password for my user, who can input their email and a password reset link is sent to their email and then the user can reset his password

But how can admin change some users password from the admin dashboard

over 4 years ago · Santiago Trujillo
4 Respostas
Responde à pergunta

0

In your admin.py file, you can register a UserAdmin to your User model like so:

from django.contrib.auth.admin import UserAdmin as DjangoUserAdmin
from django.contrib import admin
from <my-app> import models    

@admin.register(models.User)
class UserAdmin(DjangoUserAdmin):
    
    # extra logic:
    ...
over 4 years ago · Santiago Trujillo Relatório

0

Django does not store raw (clear text) passwords on the user model, but only a hash (see the documentation of how passwords are managed for full details). Because of this, do not attempt to manipulate the password attribute of the user directly. This is why a helper function is used when creating a user.

To change a user’s password, you have several options:

manage.py changepassword *username* offers a method of changing a user’s password from the command line. It prompts you to change the password of a given user which you must enter twice. If they both match, the new password will be changed immediately. If you do not supply a user, the command will attempt to change the password whose username matches the current system user.

You can also change a password programmatically, using set_password():

from django.contrib.auth.models import User
u = User.objects.get(username='john')
u.set_password('new password')
u.save()

If you have the Django admin installed, you can also change user’s passwords on the authentication system’s admin pages. Django also provides views and forms that may be used to allow users to change their own passwords.

Changing a user’s password will log out all their sessions. See Session invalidation on password change for details.

over 4 years ago · Santiago Trujillo Relatório

0

This answer is just an extension of answer by @kunal Sharma

To change user password from Django admin

Go into the user

enter image description here

and click this form, and a form below will be shown, change password there

enter image description here

over 4 years ago · Santiago Trujillo Relatório

0

We can reset other user password from Django admin interface by adding UserAdmin in admin.py file. Used Django 3.1 for the example.

admin.py

from django.contrib import admin
from .models.models import User
from django.contrib.auth.admin import UserAdmin

admin.site.register(User, UserAdmin)

Then we will able to see the below section in the user edit page of Django admin interface.

enter image description here

By clicking on the this form we can go to the reset password form.

enter image description here

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda