Automatically create an admin user when running Django’s ./manage.py syncdb

I know the question has been answered already but …

A Much simpler approach is to dump the auth module data into a json file once the superuser has been created:

 ./manage.py dumpdata --indent=2 auth > initial_data.json

You can also dump the sessions data:

./manage.py dumpdata --indent=2 sessions

You can then append the session info to the auth module dump (and probably increase the expire_date so it does not expire… ever ;-).

From then, you can use

/manage.py syncdb --noinput

to load the superuser and his session when creating the db with no interactive prompt asking you about a superuser.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)