import os
import sys
import django

# Add project root to path
sys.path.append(os.getcwd())

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
django.setup()

from django.contrib.auth import get_user_model

def reset_password():
    User = get_user_model()
    username = 'admin'
    password = 'admin'
    
    try:
        user, created = User.objects.get_or_create(username=username)
        user.set_password(password)
        user.is_staff = True
        user.is_superuser = True
        user.save()
        
        action = "created" if created else "reset"
        print(f"Successfully {action} password for user '{username}' to '{password}'.")
        
    except Exception as e:
        print(f"Error resetting password: {e}")

if __name__ == "__main__":
    reset_password()
