from django.core.management.base import BaseCommand from accounts.models import User class Command(BaseCommand): help = 'Resets non-admin account passwords to "password" and admin account passwords to "admin" using the current SECRET_KEY' def handle(self, *args, **kwargs): for user in User.objects.all(): if user.is_staff: user.set_password('admin') else: user.set_password('password') user.save() self.stdout.write("All account passwords synchronized with local SECRET_KEY.")