From f37d6601e1cefe307f0653a8854cff43f8bf969d Mon Sep 17 00:00:00 2001 From: catborise Date: Fri, 17 Apr 2020 14:03:42 +0300 Subject: [PATCH] create admin user while migrating --- accounts/migrations/0002_addAdmin.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 accounts/migrations/0002_addAdmin.py diff --git a/accounts/migrations/0002_addAdmin.py b/accounts/migrations/0002_addAdmin.py new file mode 100644 index 0000000..c0286cf --- /dev/null +++ b/accounts/migrations/0002_addAdmin.py @@ -0,0 +1,21 @@ +# Generated by Django 2.2.10 on 2020-01-28 07:01 + +from django.db import migrations + + +def add_useradmin(apps, schema_editor): + from django.utils import timezone + from django.contrib.auth.models import User + + User.objects.create_superuser('admin', None, 'admin', last_login=timezone.now()) + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0001_initial'), + ] + + operations = [ + migrations.RunPython(add_useradmin), + ]