1- # Generated by Django 4.2.3 on 2023-07-14 05:49
1+ # Generated by Django 4.2.3 on 2023-07-16 07:55
22
33import django .contrib .auth .models
44import django .contrib .auth .validators
55from django .db import migrations , models
66import django .utils .timezone
7+ from django .contrib .auth import get_user_model
8+
9+ def create_admin_user (apps , schema_editor ):
10+ User = get_user_model ()
11+ admin_username = 'admin'
12+ admin_password = '123'
13+ if not User .objects .filter (is_staff = True ).exists ():
14+ User .objects .create_superuser (admin_username , '' , admin_password )
715
816
917class Migration (migrations .Migration ):
@@ -23,7 +31,7 @@ class Migration(migrations.Migration):
2331 ('date' , models .CharField (max_length = 10 , verbose_name = 'Date' )),
2432 ('hour' , models .CharField (max_length = 10 , verbose_name = 'Hour' )),
2533 ('switch' , models .CharField (max_length = 10 , verbose_name = 'Switch' )),
26- ('host' , models .TextField (verbose_name = 'Host ' )),
34+ ('host' , models .TextField (verbose_name = 'Hosts ' )),
2735 ('playbook' , models .TextField (verbose_name = 'Playbook' )),
2836 ('output' , models .TextField (verbose_name = 'Output' )),
2937 ],
@@ -57,4 +65,5 @@ class Migration(migrations.Migration):
5765 ('objects' , django .contrib .auth .models .UserManager ()),
5866 ],
5967 ),
68+ migrations .RunPython (create_admin_user ),
6069 ]
0 commit comments