How to automate createsuperuser on django?

后端 未结 16 1571
情歌与酒
情歌与酒 2020-11-29 15:57

I want to auto run manage.py createsuperuser on django but it seams that there is no way of setting a default password.

How can I get this?

16条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-29 16:22

    As of Django 3.0 you can use default createsuperuser --noinput command and set all required fields (including password) as environment variables DJANGO_SUPERUSER_PASSWORD, DJANGO_SUPERUSER_USERNAME, DJANGO_SUPERUSER_EMAIL for example. --noinput flag is required.

    This comes from the original docs: https://docs.djangoproject.com/en/3.0/ref/django-admin/#django-admin-createsuperuser

    and i've just checked - it works. Now you can easily export those environment vars and add createsuperuser to your scripts and pipelines.

提交回复
热议问题