How to automate createsuperuser on django?

后端 未结 16 1574
情歌与酒
情歌与酒 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条回答
  •  猫巷女王i
    2020-11-29 16:32

    A solution based on Adam Charnock's approach above is available as a Python package by now. It takes three steps:

    1. Install: pip install django-createsuperuserwithpassword

    2. Activate: INSTALLED_APPS += ("django_createsuperuserwithpassword", )

    3. Apply:

      python manage.py createsuperuserwithpassword \
              --username admin \
              --password admin \
              --email admin@example.org \
              --preserve
      

    That's it.

提交回复
热议问题