Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a superuser account in Django 1.9.6

I am reading a book ("Learning Django Web Development" by Sanjeev Jaiswal and Ratan Kumar) on Django, but the book is based on an earlier version of Django (prior to version 1.9). In order to populate the database with tables, the book uses the syncdb command:

$ python manage.py syncdb 

Then the book says that terminal will prompt you to create a superuser account.

the syncdb command is no longer used in Django version 1.9 and up. After some research, it seems as if the migrate command populates the databse with tables, but it does not prompt the creation of a superuser account. How can I do this in Django 1.9.6?

like image 929
Zach W Avatar asked Jun 03 '16 15:06

Zach W


2 Answers

I think you want to run these commands:

python manage.py makemigrations creates migration files based on your models

python manage.py migrate will create the tables in your db based on the migration files created

(see docs for more details on database migrations)

python manage.py createsuperuser will create a superuser for your application in the database (docs)

like image 193
ben432rew Avatar answered Oct 03 '22 23:10

ben432rew


$ python manage.py migrate $ python manage.py createsuperuser 

https://docs.djangoproject.com/en/1.9/ref/django-admin/

like image 26
James Fenwick Avatar answered Oct 03 '22 23:10

James Fenwick