How to automate createsuperuser on django?

后端 未结 16 1586
情歌与酒
情歌与酒 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:33

    Go to command prompt and type:

    C:\WINDOWS\system32>pip install django-createsuperuser
    Collecting django-createsuperuser
      Downloading https://files.pythonhosted.org/packages/93/8c/344c6367afa62b709adebee039d09229675f1ee34d424180fcee9ed857a5/django-createsuperuser-2019.4.13.tar.gz
    Requirement already satisfied: Django>1.0 in c:\programdata\anaconda3\lib\site-packages (from django-createsuperuser) (2.2.1)
    Requirement already satisfied: setuptools in c:\programdata\anaconda3\lib\site-packages (from django-createsuperuser) (41.0.1)
    Requirement already satisfied: sqlparse in c:\programdata\anaconda3\lib\site-packages (from Django>1.0->django-createsuperuser) (0.3.0)
    Requirement already satisfied: pytz in c:\programdata\anaconda3\lib\site-packages (from Django>1.0->django-createsuperuser) (2018.7)
    Building wheels for collected packages: django-createsuperuser
      Running setup.py bdist_wheel for django-createsuperuser ... done
      Stored in directory: C:\Users\Arif Khan\AppData\Local\pip\Cache\wheels\0c\96\2a\e73e95bd420e844d3da1c9d3e496c92642a4f2181535440db2
    Successfully built django-createsuperuser
    Installing collected packages: django-createsuperuser
    

    if not executed the migration then go to django application folder and execute following

    1. python manage.py migrate
    2. python manage.py createsuperuser

    then bingo.

提交回复
热议问题