31 lines
991 B
Python
31 lines
991 B
Python
|
|
import os
|
|
import django
|
|
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'chunyu_project.settings')
|
|
django.setup()
|
|
|
|
from django.contrib.auth import get_user_model
|
|
|
|
User = get_user_model()
|
|
|
|
# 为现有测试用户设置密码
|
|
test_user = User.objects.filter(username='test@example.com').first()
|
|
if test_user:
|
|
test_user.set_password('test1234')
|
|
test_user.save()
|
|
print(f'Successfully set password for user: {test_user.username}, Email: {test_user.email}')
|
|
else:
|
|
# 尝试其他用户
|
|
test_user = User.objects.filter(email='test@example.com').first()
|
|
if test_user:
|
|
test_user.set_password('test1234')
|
|
test_user.save()
|
|
print(f'Successfully set password for user: {test_user.username}, Email: {test_user.email}')
|
|
else:
|
|
print('No test user found. Using existing user: test@example.com with password test1234')
|
|
|
|
print('\nAll users in database:')
|
|
for u in User.objects.all():
|
|
print(f' User: {u.username}, Email: {u.email}, ID: {u.id}')
|