From 618d88f1c4253b1b7133cdd697729e32c67fb8fe Mon Sep 17 00:00:00 2001 From: Real-Gecko Date: Mon, 25 May 2020 16:39:34 +0600 Subject: [PATCH] Fix default admin user - Fix error: RelatedObjectDoesNotExist: User has no userattributes. "instances/views.py", line 162, in check_user_quota --- accounts/migrations/0002_addAdmin.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/accounts/migrations/0002_addAdmin.py b/accounts/migrations/0002_addAdmin.py index c0286cf..09a91fc 100644 --- a/accounts/migrations/0002_addAdmin.py +++ b/accounts/migrations/0002_addAdmin.py @@ -6,8 +6,10 @@ from django.db import migrations def add_useradmin(apps, schema_editor): from django.utils import timezone from django.contrib.auth.models import User + from accounts.models import UserAttributes - User.objects.create_superuser('admin', None, 'admin', last_login=timezone.now()) + admin = User.objects.create_superuser('admin', None, 'admin', last_login=timezone.now()) + UserAttributes(user=admin, max_instances=-1, max_cpus=-1, max_memory=-1, max_disk_size=-1).save() class Migration(migrations.Migration):