How to allow the admin to change the uses's password in the Django admin panel? - Stack Overflow

admin2025-05-01  2

I want to allow the admin to change any user's pasword, but th admin panel doesn't have that option anymore.

I had to extend the abstract user class to add some fields to my users when they are created. I wanted to know what I can do to allow my admin users to change the user's passowrds.

This is my User class:

from django.db import models
from django.contrib.auth.models import AbstractUser

# Create your models here.
class User(AbstractUser):
    numero_de_empleado= models.CharField(max_length=100, unique=True,   default="0", verbose_name="Puente")



    class Meta:
        permissions = [
            ("view_retiro", "Ver retiro"),
            ("make_changes","Crear dotaciones y arqueos"),
            ("create_user","Crear un usuario"),
            ("view_all","Ver toda la información")
        ]

And this is my admin.py from my user app:

from django.contrib import admin
from .models import User
# Register your models here.
admin.site.register(User)

I am not an expert in django and i don't lnow why it's doing this, Thanks in advance.

I want to allow the admin to change any user's pasword, but th admin panel doesn't have that option anymore.

I had to extend the abstract user class to add some fields to my users when they are created. I wanted to know what I can do to allow my admin users to change the user's passowrds.

This is my User class:

from django.db import models
from django.contrib.auth.models import AbstractUser

# Create your models here.
class User(AbstractUser):
    numero_de_empleado= models.CharField(max_length=100, unique=True,   default="0", verbose_name="Puente")



    class Meta:
        permissions = [
            ("view_retiro", "Ver retiro"),
            ("make_changes","Crear dotaciones y arqueos"),
            ("create_user","Crear un usuario"),
            ("view_all","Ver toda la información")
        ]

And this is my admin.py from my user app:

from django.contrib import admin
from .models import User
# Register your models here.
admin.site.register(User)

I am not an expert in django and i don't lnow why it's doing this, Thanks in advance.

Share Improve this question asked Jan 2 at 17:22 Perla De la OPerla De la O 334 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

This can definitely be done in Django Admin non-programmatically:

  1. Log into Django admin with the admin or superuser account.
  2. Click on Users (or accounts depending on what you named your accounts app).
  3. That should display the table showing registered users in your app. Click on the user you want to change the password.
  4. Click on the Reset password button.
  5. Enter a new password for the user
  6. Confirm Password and click the Change Password button.

You should see the message "Password changed successfully" which confirms you've successfully changed password for the user.

转载请注明原文地址:http://www.anycun.com/QandA/1746105339a91744.html