How to supply parameters to "python manage.py syncdb" from a script?

52 views
Skip to first unread message

Dan Dong

unread,
Mar 20, 2015, 6:12:21 PM3/20/15
to django...@googlegroups.com
Hi,
  Does anybody know how to supply the input parameters to "python manage.py syncdb" from a script? E.g, to set the the followings parameters:

Would you like to create one now? (yes/no): yes
Username (leave blank to use 'root'):
Email address: xxxxxxxxx
Password: xxxxxx
Password (again): xxxxxx


Cheers,
Dan

Russell Keith-Magee

unread,
Mar 20, 2015, 7:27:12 PM3/20/15
to Django Users
You don't - and that's by design.

If you're putting a password into a script, then that script is in plain text, and so is your password - so you've just lost your security.

So - you don't pass input parameters to the script. You run the script with the --noinput flag, which will prevent the script from prompting for user input.

If you want to have an initial user in your database after syncdb, put that user's data in a fixture, and load the fixture as part of the script. The fixture will contain the password in a hashed format, so the password will be protected.

Yours,
Russ Magee %-)

Dan Dong

unread,
Mar 23, 2015, 11:08:07 AM3/23/15
to django...@googlegroups.com
Thanks Russell, that's clear now.

Cheers,
Dan


在 2015年3月20日星期五 UTC-5下午6:27:12,Russell Keith-Magee写道:
Reply all
Reply to author
Forward
0 new messages