mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2026-01-01 23:27:02 -05:00
feat: Implement initial schema and add various API, service, and management command enhancements across the application.
This commit is contained in:
@@ -7,10 +7,11 @@ sys.path.append(os.path.join(os.path.dirname(__file__)))
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "thrillwiki.settings")
|
||||
django.setup()
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth import get_user_model # noqa: E402
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
def ensure_admin():
|
||||
username = "admin"
|
||||
email = "admin@example.com"
|
||||
@@ -23,12 +24,13 @@ def ensure_admin():
|
||||
else:
|
||||
print(f"Superuser {username} already exists.")
|
||||
u = User.objects.get(username=username)
|
||||
if not u.is_staff or not u.is_superuser or u.role != 'ADMIN':
|
||||
if not u.is_staff or not u.is_superuser or u.role != "ADMIN":
|
||||
u.is_staff = True
|
||||
u.is_superuser = True
|
||||
u.role = 'ADMIN'
|
||||
u.role = "ADMIN"
|
||||
u.save()
|
||||
print("Updated existing user to ADMIN/Superuser.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
ensure_admin()
|
||||
|
||||
Reference in New Issue
Block a user