from django.contrib.auth import get_user_model
from django.core.management.base import BaseCommand

User = get_user_model()        

class Command(BaseCommand):
    help = 'Resets non-admin account passwords to "password" and admin account passwords to "admin"'

    def handle(self, *args, **kwargs):
        users = User.objects.all()
        for user in users:
            if user.is_staff:
                user.set_password('admin')
            else:
                user.set_password('password')
            user.save()
        self.stdout.write(self.style.SUCCESS(f"Successfully updated {users.count()} users."))